【发布时间】:2012-09-30 17:54:37
【问题描述】:
我很难在我的详细视图上实现简单的滚动。
该应用程序简单明了,带有主视图和详细视图。
当用户在 Master 上点击一个项目时,会推送 Detail 视图,其中包含更大的照片、博客文本等。
我希望滚动整个详细视图,因此如果图片很高,或者文字很长,他们可以垂直滚动以查看/阅读更多内容。我不希望用户单独滚动这些项目。感觉应该像网页滚动。
目前我的详细信息视图加载正常,但我无法使其滚动。
我的 DetailViewController.h
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController {
IBOutlet UILabel *postTextLabel; // wired to Text Label
IBOutlet UILabel *postAuthorNameLabel; // wired to Author Label
}
@property (strong, nonatomic) id detailItem;
@end
我的DetailViewController.m
#import "DetailViewController.h"
@interface DetailViewController ()
- (void)configureView;
@end
@implementation DetailViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self configureView];
}
- (void)configureView
{
if (self.detailItem) {
NSDictionary *post = self.detailItem;
NSString *postText = [post objectForKey:@"post_text"];
NSString *postAuthorName = [post objectForKey:@"post_author_name"];
postTextLabel.text = postText;
postAuthorNameLabel.text = postAuthorName;
}
}
@end
IB 结构:
对完成这项工作缺少什么有什么想法吗?
【问题讨论】:
-
信息不足。但是... 1) 在您的
UIScrollView中是否将scrollEnabled设置为YES? 2) 你的UIScrollView中的contentSize比frame大吗? -
3) 将您的
.h、.m和.xib文件放在某处,以便我们查看。 -
@RobertVojta h 和 m 文件如上 - 没有 xib 文件,因为我使用的是 XCode 4.5 - 还有其他建议吗?
-
如果你确实使用故事板,那么
.storyboard。
标签: objective-c ios ios5 uiview uiscrollview