Scrollview Obj C iPhone 无法滚动 - 仍然无法工作...还有其他建议吗?
我是 iPhone 新手,仍在尝试了解一切。我添加了下面的代码但仍然不起作用。使用模拟器是否有一些特殊的东西可以使其滚动?
我还将滚动视图附加到下面的 SV 中。我尝试将滚动视图移动到文本视图下方和上方,
我拥有的几个文本条目都在文本视图上
#import <UIKit/UIKit.h>
@interface UserEdit : UIViewController {
IBOutlet UIScrollView *SV;
}
@property(nonatomic, retain) IBOutlet UIScrollView *SV;
@end
//
#import "UserEdit.h"
@implementation UserEdit
- (void)viewDidLoad {
[super viewDidLoad];
SV.contentSize=CGSizeMake(320,950);
}
我已经阅读了有关滚动视图的几篇文章,但我无法使其工作。
我在界面生成器中执行了此操作:
创建了一个 UIView 并在其上放置了一个标签。运行该应用程序,效果很好。
然后我调整了 UIView 的大小,使其比普通窗口更高。
我在高窗口的顶部放置了一个滚动视图,并在整个滚动视图中放置了多个标签。
我将滚动视图作为委托附加给文件所有者。
然后我在模拟器中运行它,但无法滚动。
我需要对模拟器进行一些操作才能使其滚动,还是我做错了什么?
I am new at iPhone and still trying to understand everything. I added the code below but still doesn't work. Is there something special using the emulator maybe to make it scroll?
I also attached the scrollview to the SV below. I tried moving the scrollview under the text view and above it,
The several text entries I have are all on the text view
#import <UIKit/UIKit.h>
@interface UserEdit : UIViewController {
IBOutlet UIScrollView *SV;
}
@property(nonatomic, retain) IBOutlet UIScrollView *SV;
@end
//
#import "UserEdit.h"
@implementation UserEdit
- (void)viewDidLoad {
[super viewDidLoad];
SV.contentSize=CGSizeMake(320,950);
}
I have read several posts on the ScrollView but I am not able to make it work.
I did this in the interface builder:
I created a UIView and put a label on it. Ran the app and that worked great.
Then I resized the UIView so it was taller than the normal window.
I placed a scroll view at the top of the tall window and also placed several more labels throughout the scroll view.
I attached the scroll view as a delegate to the file owner.
Then I ran this in the simulator and I wasn't able to scroll.
Is there something with the emulator that I need to do to make it scroll or did I do something else wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确保滚动视图的 contentSize 更大。请参阅这篇文章寻求帮助。
如果 Scrollview 需要显示的内容适合其框架,则不需要滚动。
Make sure the contentSize of your scrollview is larger. refer this post for help.
Scrollview doesnt need to scroll if the contents it needs to display fits in its frame.
您需要将滚动视图属性的内容大小调整为较高的视图大小。
例如
You will need to adjust the content size of the scrollview property to the taller view size.
e.g.
您需要设置滚动视图的 contentSize 属性。将此值设置为滚动视图中包含的视图的总高度和宽度。
您只能通过代码而不是在 Interface Builder 中设置此属性。
You need to set the contentSize property of the scrollview. Set this value to the total height and width of the views contained in the scrollview.
You set this property only via code and not in Interface Builder.