Tag: 客观

如何将audio路由到扬声器而不使用AudioSessionSetProperty?

由于AudioSessionSetProperty可能会被deprecated ,我试图find一个如何使用其他方式将audio路由到speaker的代码示例。 以前我做了以下工作: -(void)setSpeakerEnabled { debugLog(@"%s",__FUNCTION__); UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; AudioSessionSetProperty ( kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride ); } 试图得到相同的结果,但without call AudioSessionSetProperty 。

设置自定义的UITableViewCells高度

我正在使用一个custome UITableViewCell有一些标签,button和图像显示。 单元格中有一个标签,其文本是NSString对象,string的长度可以是可变的。 由于这个原因,我不能在UITableViews: heightForCellAtIndex方法中为单元格设置一个不变的高度。 单元格的高度取决于可以使用NSStrings sizeWithFont方法确定的标签高度。 我尝试过使用它,但看起来我在某处出错了。 如何解决? 这里是用于初始化单元格的代码。 if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) { self.selectionStyle = UITableViewCellSelectionStyleNone; UIImage *image = [UIImage imageNamed:@"dot.png"]; imageView = [[UIImageView alloc] initWithImage:image]; imageView.frame = CGRectMake(45.0,10.0,10,10); headingTxt = [[UILabel alloc] initWithFrame: CGRectMake(60.0,0.0,150.0,post_hdg_ht)]; [headingTxt setContentMode: UIViewContentModeCenter]; headingTxt.text = postData.user_f_name; headingTxt.font = [UIFont boldSystemFontOfSize:13]; headingTxt.textAlignment = UITextAlignmentLeft; headingTxt.textColor = [UIColor […]

是否有可能刷新UITableView中的单个UITableViewCell?

我有一个使用UITableViewCell自定义的UITableView 。 每个UITableViewCell有2个button。 单击这些button将更改单元格内的UIImageView的图像。 是否可以单独刷新每个单元格以显示新图像? 任何帮助表示赞赏。

如何在UITableViewCell之间添加间距

有什么办法可以在UITableViewCell之间添加空格吗? 我创build了一个表,每个单元格只包含一个图像。 图像被分配给这样的单元格: cell.imageView.image = [myImages objectAtIndex:indexPath.row]; 但是这使得图像放大并适合整个细胞,图像之间没有间隔。 或者可以这样说,图像的高度是例如50,并且我想在图像之间增加20个间距。 有什么办法可以做到这一点?

如何将button放在UITableView上,它不会在iOS中随表格滚动

我想把button放在UITableView ,它保持在屏幕的相同位置,不会用UITableView滚动。 当我试图添加子addSubviewbutton时,它们显示,但与UITableView滚动。 把button放在UITableView原因是让用户对它进行一些操作。 我不是在说细胞中有button。 他们是浮动的button,从不移动他们的位置。 我正在使用UITableViewController ,我不想使用页眉或页脚来达到此目的。 另外一些酒吧(例如UIToolbar )不是我的select。 提前致谢。

重写isEqual的最佳实践:和散列

如何正确地重写isEqual:在Objective-C中? “catch”似乎是,如果两个对象相等(由isEqual:方法确定),它们必须具有相同的散列值。 Cocoa Fundamentals Guide的Introspection部分有一个关于如何覆盖isEqual:的例子isEqual:复制如下,名为MyWidget的类: – (BOOL)isEqual:(id)other { if (other == self) return YES; if (!other || ![other isKindOfClass:[self class]]) return NO; return [self isEqualToWidget:other]; } – (BOOL)isEqualToWidget:(MyWidget *)aWidget { if (self == aWidget) return YES; if (![(id)[self name] isEqual:[aWidget name]]) return NO; if (![[self data] isEqualToData:[aWidget data]]) return NO; return YES; } 它检查指针是否相等,然后是类的相等性,最后使用isEqualToWidget:比较对象,它只检查name和data属性。 示例没有显示的是如何重写hash […]

dequeueReusableCellWithIdentifier中的断言失败:forIndexPath:

所以我正在为我的学校做一个RSS阅读器,并完成了代码。 我跑了测试,它给了我这个错误。 这里是它所指的代码: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } 这是输出中的错误: 2012-10-04 20:13:05.356读者[4390:c07] *声明失败 – [UITableView dequeueReusableCellWithIdentifier:forIndexPath:],/SourceCache/UIKit_Sim/UIKit-2372/UITableView.m:4460 2012-10-04 20: 13:05.357阅读器[4390:c07] *由于未捕获的异常'NSInternalInconsistencyException',原因:'无法使用标识符Cell出列单元 – 必须为标识符注册一个nib或类,或者连接一个故事板中的原型单元“*第一掷调用堆栈:(0x1c91012 0x10cee7e 0x1c90e78 0xb64f35 0xc7d14 0x39ff 0xd0f4b 0xd101f 0xb980b 0xca19b […]