Tag: 客观

如何播放没有指向铃声音量的audio?

我有一个简单的声卡应用程序与几个不同类别的声音。 我正在使用AudioToolbox.framework(我的所有声音文件基本都在10秒钟内,都是.wav文件),但是我很困惑如何让我的应用程序引用“音量”音量,而不是“Ringer”音量。 如果我的设备设置为“无声”,即使设备音量打开,我的button也不会播放声音。 但是,只要打开“Ringer”(位于设备侧面),就会响起铃声。 我在网上search,发现一些来源,说我的AVAudioSession切换到AVAudioSessionCategoryPlayback,所以我粘贴 AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *setCategoryError = nil; BOOL success = [audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError]; if (!success) { /* handle the error condition */ } NSError *activationError = nil; success = [audioSession setActive:YES error:&activationError]; if (!success) { /* handle the error condition */ } 到我的viewDidLoad。 但是,也会出现同样的问题。 我在网上发现了其他的build议,但是这些解释让我对我应该做的事感到困惑。 我对Objective-C和编码相对来说比较陌生,所以如果你知道答案,请在你的解释中具体清楚。 我很高兴地感谢您提供的任何帮助。 编辑一我跟随了Pau […]

iOS:Tableview开始更新从不播放animation

我写了一些代码,当用户长按一个单元格并确认更改时,从后端和本地数据存储中删除一个post。 但是,tableview不会更新。 我已经突破了我的代码和tableView操作代码被执行,为什么我的行不被从视图中删除? let alertView = UIAlertController(title: "Really?", message: "Are you sure you want to delete this post? Once you do it will be gone forever.", preferredStyle: .Alert) alertView.addAction(UIAlertAction(title: "Delete Post", style: UIAlertActionStyle.Default, handler: { (alertView:UIAlertAction!) -> Void in let p = post.getRawPost() p.deleteInBackgroundWithBlock({ (deleted:Bool, error:NSError?) -> Void in // Remove from the local datastore […]

更改自定义tableViewCell的背景颜色

我想改变我的细胞的背景颜色 我看到其他问题,但他们不符合我的情况 我想做一个通知tableView 例如,如果用户已经读取单元格,单元格的背景颜色将变为白色 如果不是,颜色是黄色的 开始时 我设置了颜色 -(void)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{ if(read[[indexPath row]]) [cell.backView setBckgroundColor:[UIColor whiteColor]; else [cell.backView setBckgroundColor:[UIColor redColor]; } 它的工作原理,然后我想改变颜色 tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{ read[[indexPath row]] = yes; [cell.backView setBckgroundColor:[UIColor whiteColor]; cell.name.text = @"test"; } 它也可以 但是,如果我select其他细胞,它改变为原始的颜色 看来只能同时改变一个单元格的颜色 不pipe我用 cell.backgroundColor cell.contentView.backgroundColor cell.backView 它得到了同样的结果,任何人都可以帮助我 编辑4/20 20:13 我设置了阅读 tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath 抱歉误导,我更新代码 和我select其他单元格后,我不调用[tableView重载] 所以我不认为这是原因 顺便说一下,一切(如标签)可以改变,但背景颜色 如果我select单元格,则通过导航跳转到其他屏幕 答 结论第一 tableView: cellForRowAtIndexPath: […]

AFNetworking 2.0 setImageWithURLRequest

我在当前的项目中下载图片时使用了这段代码,并没有与AFNetworking 2.0一起工作。 我试图通过AFImageResponseSerializer,但我找不到合适的代码使用。 [cell.posterImage setImageWithURLRequest:urlRequest placeholderImage:[UIImage imageNamed:@"placeholder.png"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) { cell.posterImage.image = image; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) { NSLog(@"Request failed with error: %@", error); }]; 关于AFNetworking 2.0中使用的新代码的任何build议? 谢谢!

当tableview滚动时计数值被改变

这是我的CellForRowAtIndexPath代码 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; { static NSString *simpleTableIdentifier = @"PickAClassCell"; cell = (PickAClassCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"PickAClassCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } cell.CountLabel.tag=1000; [cell.PlusCount addTarget:self action:@selector(PlusButtonSelect :)forControlEvents:UIControlEventTouchUpInside]; return cell; } -(void)PlusButtonSelect :(UIButton *)sender { UILabel *label1 = (UILabel *)[sender.superview viewWithTag:1000]; NSLog(@"%@",label1); […]

修剪UIImage白色边框

我无法find一种方法来裁剪包含白色边框的图像。 目前这是一个UIImage,我尝试了一些解决scheme,如UIImage + Trim和CKImageAddons,但这些库不工作。 我认为问题的一部分是,由于图像压缩(我认为), 边框不是完美的白色 。 有没有人find这个解决scheme? 谢谢,

UiTableView标题不会消失

我有一个UITableViewconfiguration为普通样式,所以我可以将表头视图停留在表的顶部,直到另一个标题将其拉下。 问题是:如果我有一个标题卡在屏幕的顶部,并以编程方式滚动到表的另一部分(该标题不应该出现在那里),该UIView将不会被解雇。 也就是说,如果我再次滚动到表格的那一部分,那么这个表头的一个鬼影将在表格的那个部分上可见。 我已经实现了方法- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(nonnull UIView *)view forSection:(NSInteger)section来理解发生了什么。 我发现,如果我手动滚动,直到一个标题拉离屏幕,这个委托被调用。 但是,如果我以编程方式滚动,代理不会被调用。 顺便说一句,我试着用两种不同的方法编程滚动,问题是一样的。 – (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; – (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated; 我可以想象的一个解决方法是实现- (void)scrollViewDidScroll:(UIScrollView *)scrollView; ,筛选可见屏幕之外的所有标题视图,并从超级视图中删除它们。 我可以让它工作,但我想知道是否还有其他更好的解决scheme。 [编辑]如果我调用- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; 与animation= YES,错误不会发生。 我可以去这个解决scheme,但我真的希望在一些情况下滚动没有animation。

表视图麻烦与出列单元格

所以我无法在UITableView显示数据。 我相信这与重用单元格有关。 我已经在网上查询,但没有find适合我的解决scheme。 任何帮助,将不胜感激。 我有一个由文本和图片填充的数组。 我然后在tableView显示信息。 如果我使用静态大小的单元格,一切正常,但文本的数量发生了变化,所以我也实现了heightForRowAtIndexPath方法。 这也适用,直到我滚动到底部。 之后,当我向上滚动时,所有的单元格高度都会改变,显示将全部混乱。 一些文本被截断,图片被切碎,一些单元格只有文本的最后部分。 我真的认为这与重用单元格有关,但我不知道如何解决这个问题。 以下是我的代码cellForRowAtIndexPath和heightForRowAtIndexPath 。 – (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:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } if ([[_theBigArray objectAtIndex:indexPath.row] isKindOfClass:[NSString class]]) { NSString *label = [_theBigArray objectAtIndex:indexPath.row]; CGSize […]

在UITableView-XMLparsing中混合了图像

编辑:其实图像显示正常,这是当我滚动,他们混在一起… 我正在parsing一个XML文件,并将其链接到我正在放入UITable的图像中。 出于某种原因,图片变得混乱起来,当我向下滚动桌子时,他们中的一些甚至开始改变! 这里是我用于我的UITable的代码: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; Tweet *currentTweet = [[xmlParser tweets] objectAtIndex:indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; CGRect imageFrame = CGRectMake(2, 8, 40, 40); customImage = [[UIImageView alloc] initWithFrame:imageFrame]; [cell.contentView addSubview:customImage]; } NSString *picURL […]

在Firebase中填充UITableView一次设置单元格数量

我正在使用Firebase来填充UITableView 。 我想知道是否有可能让Firebase下载前5个结果,并且一旦用户滚动到最后的结果,就下载下5个结果。 目前,Firebase一次下载我的所有子节点,但是如果它一点一点地执行,则视图将加载得更快。 有什么build议? – 编辑 注意到单元格中有图像是很重要的。 图像是base64编码的NSString s。 这里是我用来检索它们并将它们转换成UIImage的代码 NSString* profPicString = [child.value objectForKey: @"profilePicture"]; NSData *dataFromBase64 = [NSData base64DataFromString:profPicString]; UIImage *profPicImage = [[UIImage alloc]initWithData:dataFromBase64]; item.profilePicture = profPicImage;