小编Ale*_*der的帖子

在此区块中强烈捕获"自我"可能会导致保留周期

我需要阻止.但编译器会发出警告

"在这个区块强势捕捉'自我'可能会导致保留周期"

__weak typeof(self) weakSelf = self;
[generalInstaImage setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:data[@"images"][@"low_resolution"][@"url"]]] placeholderImage:[UIImage imageNamed:@"Default"] success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
    NSLog(@"success");
    [generalInstaImage setImage: image];
    [weakSelf saveImage:generalInstaImage.image withName:data[@"id"]];

    } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
        NSLog(@"fail");
}];
Run Code Online (Sandbox Code Playgroud)

我尝试编写类似的例子weakSelf.generalInstaImage,但编译器生成错误而不编译.

objective-c ios objective-c-blocks automatic-ref-counting retain-cycle

19
推荐指数
1
解决办法
2万
查看次数

UITableView获取UIScrollView进行自定义

我有UIScrollView自定义类别

我需要得到UIScrollView.

我试试

UIScrollView *scroll = nil;
for (UIView* subview in self.tableView.subviews) {
    NSLog(@"%i", self.tableView.subviews.count);

    if ([subview isKindOfClass:[UIScrollView class]]) {
        scroll = (UIScrollView *)subview;
        //some code
    }
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我怎么能得到ScrollView?谢谢

iphone objective-c uitableview uiscrollview ios

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

由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [__ NSDictionaryI sizeWithFont:constrainedToSize:lineBreakMode:]

我是新手程序员.已经晚上试图解决问题,但没有奏效.我正在尝试根据信息内容动态更改单元格的大小.举个例子,但我的程序启动死了.有错误:

 'Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '-[__NSDictionaryI sizeWithFont:constrainedToSize:lineBreakMode:]"     
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
    }

    NSDictionary *newsItem = [news objectAtIndex:indexPath.row];

    cell.textLabel.text = [newsItem objectForKey:@"title"];

    cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
    cell.textLabel.numberOfLines = 0;

    cell.detailTextLabel.text = [newsItem objectForKey:@"pubDate"];
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cellText = [news objectAtIndex:indexPath.row];
    UIFont *cellFont = [UIFont fontWithName:@"Helvetica-Bold" …
Run Code Online (Sandbox Code Playgroud)

cell uitableview ios

2
推荐指数
1
解决办法
2678
查看次数

如何从 PDF 获取 UIImage

给我提供 pdf 的网址。我需要一个 4 页的 pdf 文件来获取 UIImage,但不是全部,而是页面的一部分。请告诉我如何使这更容易。感谢您花费的时间例子

pdf uiimage ios

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

Tumblr的UIDocumentInteractionController

我需要在Tumblr中分享照片,在iOS中使用app Tumblr.

对于Instagram我喜欢这样:

  NSData *imageData = UIImageJPEGRepresentation(self.test.image, 1.0);

    NSString *writePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"instagram.igo"];
    if (![imageData writeToFile:writePath atomically:YES]) {
        NSLog(@"image save failed to path %@", writePath);
        return;
    } 

    // send it to instagram.
    NSURL *fileURL = [NSURL fileURLWithPath:writePath];
    self.documentController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
    [self.documentController setUTI:@"com.instagram.exclusivegram"];
    [self.documentController setAnnotation:@{@"InstagramCaption" : @"#hey"}];

    if (![self.documentController presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES]) NSLog(@"couldn't present document interaction controller");
Run Code Online (Sandbox Code Playgroud)

但是我不知道怎么会这样,但对于Tumblr,谢谢

iphone sharing tumblr ios

0
推荐指数
1
解决办法
606
查看次数