小编Gle*_*ith的帖子

如果url存在Objective-c

嘿,我有一个程序需要判断一个在线图像是否存在,但我唯一能让它工作的方法是在NSData指针中加载图像并检查指针是否存在.

- (BOOL)exists {
      NSString *filePath = @"http://couleeapps.hostei.com/BottomBox.png";
      NSURL *url = [NSURL URLWithString:filePath];
      NSData *imageData = [NSData dataWithContentsOfURL:url];
      if (imageData) {
            return YES;
      }
            return NO;
}
Run Code Online (Sandbox Code Playgroud)

这对我有用,但我的问题是我的连接速度非常慢,下载图像需要花费很长时间.所以我的问题是:有没有办法检查图像(说" http://couleeapps.hostei.com/BottomBox.png ")是否可用,而无需在布尔报告方法中下载?

非常感谢帮助

HiGuy

url image exists objective-c download

4
推荐指数
1
解决办法
4052
查看次数

删除灰色UITableView索引栏

我正在使用UITableView创建一个具有几个部分(2)的应用程序,当我运行时,表视图侧面有这个恼人的灰色索引栏,就像"iPod"应用程序中的那个,只有2个选项在里面.我的问题是,如何隐藏"索引栏",因为这是不必要的空间浪费?

示例:http:
//img824.imageshack.us/img824/7278/grayscrollbar.png

代码片段:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [sections count];
}

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
    return sections;
}

// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 2;
    }
    return 1;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [sections objectAtIndex:section];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell …
Run Code Online (Sandbox Code Playgroud)

objective-c scrollbar hide uitableview

4
推荐指数
2
解决办法
6889
查看次数

UITableView没有正确选择

我正在开发一个iPhone应用程序,我有一个UITableView,它通过URL填充XML feed.

比如说,填充了三个单元格.

如果我点击第一个单元格没有任何反应,但是如果我点击第二个或第三个单元格,它会将我带到与第一个单元格相关的第二个屏幕,而其他单元格也会发生同样的情况 - 点击它没有任何东西,点击另一个单元格它将我带到前一个选定的第二个屏幕.

我从来没有遇到过这种情况而且很困惑.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                              reuseIdentifier:@"UITableViewCell"];
    }

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    LocationsItem *atm = [[locations atms] objectAtIndex:[indexPath row]];
    [[cell textLabel] setText:[atm atmName]];

    float distance = [[atm atmDistance] floatValue];
    NSString *distanceString = [NSString stringWithFormat:@"%0.2f miles from current location", distance];
    [[cell detailTextLabel] setText:distanceString];

    return cell;
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    LocationsItem *atm = [[locations …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview

4
推荐指数
1
解决办法
1756
查看次数

在Objective C中将相对URL更改为绝对URL

我如何获取应用程序目录中的文件(.app所在的文件夹),并获取它的绝对路径.假设相对路径是"Data/file.txt",我如何使用Objective C将其作为绝对路径?我有用户输入他们的主文件夹名称,如果这是任何帮助.

请帮忙,

HiGuy

url xcode objective-c relative-path absolute-path

3
推荐指数
1
解决办法
8971
查看次数