非常简单的问题,但在Apple的文档中似乎并不清楚.
将writeToFile:atomically:
用于NSData
,NSArray
等覆盖在文件上现有的数据?
YouTube频道可以包含多个"相关"频道的列表.例如,音乐频道有相关的流派频道:嘻哈,流行,摇滚,乡村等.
音乐频道:http://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ
音频频道的相关频道:http://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ/channels
我可以使用youtube.search.list
API 检索频道中的视频列表,我可以使用youtube.channels.list
API 获取特定频道的数据,但我似乎无法找到任何能够提供"与频道相关的其他频道"的API,如上例所示.
我很确定我看了谷歌提供的所有API都提供了https://developers.google.com/apis-explorer/#p/youtube/v3/
无论如何我可以获取我需要的数据吗?
我已经将UINavigationBar的高度定制为100px,我想在这个自定义栏上添加按钮.
一切都很好,除了按钮似乎想要坐在导航栏的底部,无论如何.我不能让它与导航栏的中心或顶部对齐.
这是代码; 首先,我在app delegate中创建一个导航控制器,并在右侧添加一个按钮.
// set main navigation controller
temp *tempc = [[temp alloc] initWithNibName:@"temp" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:tempc];
UIBarButtonItem *navItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
[tempc.navigationItem setRightBarButtonItem:navItem];
[self.window addSubview:self.navigationController.view];
[self.window makeKeyAndVisible];
Run Code Online (Sandbox Code Playgroud)
然后我在"临时"视图控制器中调整导航栏的大小,如下所示:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
CGRect frame = CGRectMake(0.0f, 0.0f, 320.0f, 100.0f);
[self.navigationController.navigationBar setFrame:frame];
[self.navigationController.navigationBar setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin];
}
Run Code Online (Sandbox Code Playgroud)
我还尝试向rightBarButtonItem添加自定义视图,但我无法将添加的自定义视图完全触及顶部.
这个不幸的尝试的代码:
// set main navigation controller
temp *tempc = [[temp alloc] initWithNibName:@"temp" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:tempc];
UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, …
Run Code Online (Sandbox Code Playgroud) objective-c uinavigationbar uinavigationcontroller uinavigationitem ios
我在我的iOS应用程序上使用Facebook的iOS SDK 3.7来处理登录.当我请求发布权限时,看起来过期日期是从登录之日起大约2个月.
我知道我可以使用[FBSession activeSession].accessTokenData.expirationDate
但是会发生什么来检查到期日期,以及如何在令牌过期时处理令牌?
我又跑[FBSession openActiveSessionWithReadPermissions:allowLoginUI:completionHandler:];
了吗?
我正在使用NSFetchedResultsController将数据填充到UITableView上.这是一个简单的聊天应用程序,我想先将最新的25条消息加载到桌面上,然后在用户向上滚动以查看较旧的消息时加载更多消息(聊天消息按升序排列).
我为willDisplayCell中的NSFetchedResultsController调用了一个setFetchLimit的方法:就像这样....
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 0)
{
[self performSelector:@selector(getMoreMessages) withObject:nil afterDelay:1.0];
}
}
Run Code Online (Sandbox Code Playgroud)
当显示UITableView的第一行时,getMoreMessages将尝试重置fetchLimit重新加载UITableView,就像这样......
- (void)getMoreMessages
{
maxListItems += 25;
NSLog(@"set maxListItems: %d", maxListItems);
[self.resultsController.fetchRequest setFetchLimit:maxListItems];
[self._tableView reloadData];
}
Run Code Online (Sandbox Code Playgroud)
但是,它似乎不起作用,表数据不会改变.最初的NSFetchRequest设置如下......
NSFetchRequest *chatDataRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"ChatData" inManagedObjectContext:appDelegate.managedObjectContext];
[chatDataRequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(key != 0 OR messageNo != 0) and matchNo = %d", matchNo];
[chatDataRequest setPredicate:predicate];
NSSortDescriptor *sortDescripter1 = [[NSSortDescriptor alloc] initWithKey:@"status" ascending:YES];
NSSortDescriptor *sortDescripter2 = [[NSSortDescriptor …
Run Code Online (Sandbox Code Playgroud) 我有一个带有调用的MKMapView的视图控制器
[self.mapView setRegion:region animated:YES];
Run Code Online (Sandbox Code Playgroud)
将地图从A重新定位到B.
保存MKMapView的视图控制器被设置为委托和in
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
Run Code Online (Sandbox Code Playgroud)
我有一些代码会触发另一个setRegion:animated:到MKMapView,以便地图自动放大新位置.
如果我popViewControllerAnimated,一切正常:视图控制器在MKMapView动画完成平移和缩放之后.
但是,当我尝试popViewControllerAnimated时:当前视图控制器在MKMapView运行它的动画时,应用程序崩溃,"消息发送到解除分配的实例".
从调试器的外观来看,我认为MKMapView正试图从弹出和释放的委托中调用一个方法.
所以我试过了
[self.mapView setDelegate:nil];
self.mapView = nil;
Run Code Online (Sandbox Code Playgroud)
在viewDidUnload中没有运气.该应用程序仍然一直崩溃.
我能想到的唯一的事情是创建一个单独的新的委托类和保留从父视图控制器类,以便将的MKMapView有一个代表包含它的视图控制器被释放后还要打电话.
为什么会这样?还有其他"干净"的选择吗?
我有一些使用KVO的代码,并且在多个地方都有addObserver:forKeyPath:和removeObserver:forKeyPath : . 该应用程序偶尔会崩溃"无法移除观察者的关键路径".
我想知道是否可以安全地尝试/捕获异常以防止应用程序崩溃.我知道这不是处理KVO的最佳方法,但我需要花一些时间才能清理代码.
cocoa objective-c key-value-observing nsnotificationcenter ios
我有一个应用程序,基本上可以用来下载,上传和管理各种Web服务的照片.
我希望图像列表视图看起来像iOS照片应用程序,但不太确定最好的方法是什么.
我以为我可以使用NSMutableArray和子类UIScrollView从头开始创建该功能,但我真的很想使用NSFetchedResultsController,因为在Core Data中动态/异步更新/插入/删除了与图像相关的一些数据.
现在我已经设置了一些非常hacky的东西.
我创建了一个单独的Core Data实体来保存每个托管对象中4张照片的关系,并通过它们创建了UITableView循环.然后,cellforrow委托将遍历每个表格单元格中的4张照片.这种方法很糟糕,因为很难动态删除和插入照片,每次更新时我都必须重建关系并重新加载表格.
我看过其他一些库,但是我真的很想知道最简单有效的方法是什么.
ios ×6
objective-c ×6
cocoa ×2
iphone ×2
cocoa-touch ×1
core-data ×1
facebook ×1
google-api ×1
mkmapview ×1
uitableview ×1
youtube ×1
youtube-api ×1