ObjectiveC iPhone ScrollView [英] ObjectiveC iPhone ScrollView

查看:72
本文介绍了ObjectiveC iPhone ScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的程序员,



我已经开始使用iPhone应用程序而且我一直在努力解决一些问题。

最困难的部分是设计界面。



现在我知道有一个GUI设计师,但是,这不是设计内容的理想工具scrollviewer,因为你仍然有screendis的限制。



现在我已经在代码中执行此操作,如下所示:



Dear coders,

I''ve started working on an iPhone app and i''ve been struggling with a few things.
The most struggled part is designing the interface.

Now I know there is a GUI designer, however, this is not the ideal tool to design items for within a scrollviewer, since you still have the limitation of the screendisplayed.

Now I''ve been doing this in code, looking like the following:

- (void)addUserDetailViews
{
    lblUserDetailTitle = [[UILabel alloc] initWithFrame:CGRectMake(20, 30, 280, 21)];
    lblUserDetailTitle.text = @"User Details";
    lblUserDetailTitle.font = [UIFont boldSystemFontOfSize:18];
    lblUserDetailTitle.backgroundColor = [UIColor clearColor];
    [self.scrollView addSubview:lblUserDetailTitle];

    lblUserDetailBreakLine = [[UILabel alloc] initWithFrame:CGRectMake(20, 48, 280, 1)];
    lblUserDetailBreakLine.backgroundColor = [UIColor cyanColor];
    [self.scrollView addSubview:lblUserDetailBreakLine];

    lblUserDetailId = [[UILabel alloc] initWithFrame:CGRectMake(30, 60, 120, 21)];
    lblUserDetailId.text = @"ID";
    lblUserDetailId.font = [UIFont systemFontOfSize:15];
    lblUserDetailId.backgroundColor = [UIColor clearColor];
    [self.scrollView addSubview:lblUserDetailId];

    lblUserDetailDescription = [[UILabel alloc] initWithFrame:CGRectMake(30, 88, 120, 21)];
    lblUserDetailDescription.text = @"Name";
    lblUserDetailDescription.font = [UIFont systemFontOfSize:15];
    lblUserDetailDescription.backgroundColor = [UIColor clearColor];
    [self.scrollView addSubview:lblUserDetailDescription];
}





我可以理解这不是创建iPhone / iPad应用程序的最佳方式..



现在我正在寻找一种方法,只需设计师使用对象工具包即可。



我要问这个问题的主要原因是因为我需要大约50行......并且以这种方式实现这一点,可能会为iPad版或其他任何东西搞砸。



有没有人可以告诉我如何做到这一点?



你真诚的,

larssy1



I can understand that this is not the best way to create an iPhone / iPad app..

Now i''m actually looking for a way to do this simply by the designer using the object toolkit.

The main reason i''m asking this is because i''d need to have about 50 rows.. and accomplishing that in this way, might screw things up for an iPad version or what ever.

Is there anyone who could tell me how to accomplish this?

Yours Sincerely,
larssy1

推荐答案

看起来你真正想要的是使用UITableView。当你有如你所描述的数据行时,它是在iOS中使用的标准UI元素。



看看这个链接:

http://developer.apple.com/library /ios/#documentation/userexperience/conceptual/tableview_iphone/tableviewstyles/tableviewcharacteristics.html [ ^ ]



UITableView处理所有的布局和格式行/部分 - 你只需告诉它你想要的样式,并提供一些方法,它可以调用以获取每行中的实际数据。



那个并不一定回答你关于如何在d中布局长视图的问题esigner,但它确实解决了你所描述的问题。



如果你真的需要在设计师中布置长视图,我相信可以暂时改变您正在设计的视图的大小(高度),以便您可以查看滚动视图的整个长度,然后在保存之前将其更改回实际高度。 (至少在之前版本的XCode中可能 - 我下载的最后一个版本有很多东西重新安排和更改,我没有时间弄清楚所有控件/选项何时到更不用说弄清楚什么不再起作用了。)
It looks like what you really want is to use a UITableView. It''s the standard UI element to use in iOS when you have rows of data like you are describing.

Take a look at this link:
http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/tableviewstyles/tableviewcharacteristics.html[^]

The UITableView handles the layout and formatting of all the rows / sections -- you just tell it what style you want, and provide some methods that it can call to get the actual data that goes in each row.

That doesn''t necessarily answer your question about how to layout a long view in the designer, but it does solve the problem you are describing.

If you really need to layout a long view in the designer, I believe it is possible to temporarily change the size (height) of the view you are designing so you can see the whole length of the scroll view, and then change it back to the actual height before you save it. (At least that was possible in the previous version of XCode -- the last version I downloaded had a lot of things re-arranged and changed, and I haven''t had the time to figure out where all the controls/options when to, much less figure out what doesn''t work any more.)


这篇关于ObjectiveC iPhone ScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆