我需要阻止.但编译器会发出警告
"在这个区块强势捕捉'自我'可能会导致保留周期"
__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
我有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
?谢谢
我是新手程序员.已经晚上试图解决问题,但没有奏效.我正在尝试根据信息内容动态更改单元格的大小.举个例子,但我的程序启动死了.有错误:
'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) 给我提供 pdf 的网址。我需要一个 4 页的 pdf 文件来获取 UIImage,但不是全部,而是页面的一部分。请告诉我如何使这更容易。感谢您花费的时间
我需要在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,谢谢
ios ×5
iphone ×2
objective-c ×2
uitableview ×2
cell ×1
pdf ×1
retain-cycle ×1
sharing ×1
tumblr ×1
uiimage ×1
uiscrollview ×1