Tag: 客观

如何以编程方式从iOS设备获取自己的手机号码?

我想为我的应用程序获取我自己的联系人号码。 我已经阅读了堆栈溢出的一些答案,但那些是旧的。 所以请根据苹果的新指引告诉我,我们可以拿到手机号码吗? 谢谢

dynamic地改变目标C中单元的高度

我创build了一个表视图的应用程序。 在每个单元格中使用视图和标签。 但是,如果我在(!单元格)代码中创build视图和单元格,它会返回空单元格,如果删除(!单元格)条件,则会显示数据但不会占用dynamic高度。 谁能帮帮我吗。 – (void)viewDidLoad{ NSString *Path = [[NSBundle mainBundle] bundlePath]; NSString *DataPath = [Path stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.plist", LanguageFile]]; NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] initWithContentsOfFile:DataPath]; self.reloadArray = [tempDict objectForKey:@"Rows"];} -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.reloadArray count]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1; } – (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { // Get data for the current […]

只刷新UITableView中的自定义标题视图?

我的UITableView在每个部分都有自定义的UIView标题。 我只需要刷新标题,而不是部分中的其他内容。 我试过[self.tableView headerViewForSection:i] ,它不会返回任何东西,即使它应该。 无论如何,我可以做到这一点? 编辑:基于新build议的代码 我已经给了这个镜头,它调用/更新该方法内的UIView,但更改不会直观地传播到屏幕上。 for (int i = 0; i < self.objects.count; i++) { UIView *headerView = [self tableView:self.tableView viewForHeaderInSection:i]; [headerView setNeedsDisplay]; }

如何检索所有可见的表节标题视图

有没有办法让所有的节标题视图是可见的? 类似于UITableView的visibleCells实例方法

UICollectionView:有没有办法只重新加载补充意见?

我有一个与每个部分的补充视图的uicollectionview。 在每个补充视图中我都有一些button。 在dataSource方法collectionView:viewForSupplementaryElementOfKind:atIndexPath:我使用indexPath.section设置button标签。 当按下button时,我做了一些委托方法,并发送部分(button.tag)作为参数。 一切工作正常,但问题来了: 当我插入或删除一个部分,它必须更新button标签,但我不想重新加载每个部分的所有项目。 我试过了: 使用dataSource方法collectionView:viewForSupplementaryElementOfKind:atIndexPath:来获取补充视图,并为每个辅助 视图调用layoutIfNeeded方法,这样补充 视图就是重新加载的,但是这种方法会乘以我的补充 视图 。 一个快速的在collectionView.subviews并得到只是补充 视图和调用layoutIfNeeded方法,但它不重新加载,只是布局正在重新加载。 reloadSections:方法,但会重新加载该部分的所有项目 哦,我使用NSFetchedResultsController (委托)插入和删除部分。 谁能帮我这个? 有没有办法只重新加载补充视图 ? 这种情况下还有其他方法吗? 谢谢!

不调用cellForItemAtIndexPath,但numberOfItemsInSection

这可能是一个重复的post,但我还没有find任何解决scheme: 我设置我的UICollectionView为: UINib *nib = [UINib nibWithNibName:@"CollectionViewCell" bundle:[NSBundle mainBundle]]; [_collectionView registerNib: nib forCellWithReuseIdentifier:@"bCell"]; (我试图设置代表,没有委托,等等)。 但是,只有这个 – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section被调用while – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath不。 我检查了numberOfItemsInSection我返回,它总是> 0(正好17)。 我已经检查过要调用[_collectionView reloadData]; 也没有任何反应。 我尝试过不同的事情,但是我无法做到这一点。 此外,我的UICollectionView应该在这里,但它不是: 有人有线索吗? 谢谢。

适用于iOS的Swift TableView

我提到了这个问题 ,并试图实现各种答案。 我正在做一些愚蠢的事情,因为cellForRow没有被调用,我只是得到一个空白的tableView。 是否有其他数据源或委托方法,我必须重写? 谢谢 class ViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. //tableView.delegate = self //tableView.dataSource = self tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: "Cell") //tableView.registerClass(MyTableViewCell.self, forCellReuseIdentifier: "Cell") tableView.reloadData() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. […]

将十进制经度/纬度坐标转换为iPad屏幕坐标

我有一个纬度/经度的小数坐标,我想转换成适合iPad坐标系统的区域的点。 我的代码需要经纬度坐标,并将它们转换为笛卡尔坐标(基于此问题: 转换为直angular坐标 )转换的结果是(2494.269287,575.376465)。 这是我的代码(没有编译或运行时错误): #define EARTH_RADIUS 6371 – (void)drawRect:(CGRect)rect { CGPoint latLong = {41.998035, -116.012215}; CGPoint newCoord = [self convertLatLongCoord:latLong]; NSLog(@"Cartesian Coordinate: (%f, %f)",newCoord.x, newCoord.y); //Draw dot at coordinate CGColorRef darkColor = [[UIColor colorWithRed:21.0/255.0 green:92.0/255.0 blue:136.0/255.0 alpha:1.0] CGColor]; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, darkColor); CGContextFillRect(context, CGRectMake(newCoord.x, newCoord.y, 100, 100)); } -(CGPoint)convertLatLongCoord:(CGPoint)latLong { CGFloat x […]

在iOS中创build我自己的完成块

我有一个对象,需要很长时间做一些东西(它从服务器下载数据)。 我怎么写我自己的完成块,以便我可以运行… [downloader doSomeLongThing:^(void) { //do something when it is finished }]; 我不知道如何将这个块保存在下载器对象中。

iOS 9如何检测静音模式?

由于AudioSessionInitialize和AudioSessionGetProperty被弃用,我得到错误的返回值: CFStringRef state = nil; UInt32 propertySize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); OSStatus status = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state); [[AVAudioSession sharedInstance] setActive:YES error:nil]; if (status == kAudioSessionNoError) { return CFStringGetLength(state) == 0; // YES = silent } return NO; 从这个代码(我在这里find它),我得到同样的不正确的结果,不pipe什么状态实际上设备上。 如何检测设备上的静音模式是否开启?