小编dag*_*r24的帖子

ios:如何使用滚动视图将图像从URL加载到页面控件

我是iOS的新手.现在我想使用滚动视图将视图图像从URL加载到页面控件.当我运行该程序时,显示第一个图像,但当我尝试滑动到下一个图像或我移动到另一个页面时,程序没有响应.我的猜测可能与图像的大小有关.

以下是我加载图像的代码.我将此代码放入 - (void)viewDidLOad ...

CGRect screenShot = screenView.frame;
screenShot.origin.y = description.frame.origin.y + description.frame.size.height + 30;
screenView.frame = screenShot;

pageControlBeingUsed = NO;

for (int i = 0; i < [myArrayImagesURL count]; i++) {
    CGRect frame;
    frame.origin.x = self.scrollView.frame.size.width * i;
    frame.origin.y = 0;
    frame.size = self.scrollView.frame.size;
      UIImageView *iv = [[[UIImageView alloc] initWithFrame:CGRectMake(scrollView.bounds.size.width * i, 0, scrollView.bounds.size.width, scrollView.bounds.size.height)] autorelease];
    iv.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
                                       [NSURL URLWithString:[myArrayImagesURL objectAtIndex:i]]]];

    [self.scrollView addSubview:iv];
    [iv release];
}

self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * [myArrayImagesURL count], self.scrollView.frame.size.height);

self.pageControl.currentPage = …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c scrollview uipagecontrol ios

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

iOS如何获取,当前在cellForRowAtIndexPath方法中选择了indexpath行?

我想在表格的每个单元格中使用标签建立链接.

单击链接时,表将获取单元格的[indexpath行],我们将使用索引与包含字符串数据的数组索引匹配.该字符串将被发送到下一个推送页面.

我正在使用UITapGestureRecognizer来点击标签并将参数放入选择器方法.

如何获取当前索引路径行所选单元格上的标签?这是我的示例代码:

 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
...
UITapGestureRecognizer *gestureRec = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openUrl:) ];
gestureRec.numberOfTouchesRequired = 1;
gestureRec.numberOfTapsRequired = 1;
[cell.listPrice addGestureRecognizer:gestureRec];
[gestureRec release];
...
}


- (void)openUrl:(id)sender
{
NSLog(@"DOwnload URL send >> %@",urlDownloadSend);
DownloadNowController *download =[[DownloadNowController alloc]initWithNibName:@"DownloadNowController" bundle:nil];
[self.navigationController pushViewController:download animated:YES];
[download release]; 
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitableview uigesturerecognizer ios

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