开发者

How do I programatically add a view into another view loaded from a XIB file?

I have a XIB file (view) that has a toolbar and a view right belo开发者_C百科w it, as illustrated in the image below:

How do I programatically add a view into another view loaded from a XIB file?

You can also view the image here.

I am using the following PhotoScroller: http://developer.apple.com/library/ios/#samplecode/PhotoScroller/Introduction/Intro.html

The problem is that the PhotoScroller is dynamically created into the method loadView and directly assigned to its own view. That makes the PhotoScroller fills up the entire screen, which is not what I want.

I want to be able to put the PhotoScroller only inside the view that is below the toolbar (that is, the view numbered 2 in the picture above).

I think I have to load the view that is inside the XIB file and assign the PhotoScroller to that view. However, I have no idea how to do that (or if that`s even the solution).

How could I do that?

PS: Even though the number 2 shows a list, it is not a list! Its just a simple blank view (I just couldnt find a better image to put here).

Thank you in advance! :)


Instead of doing

self.viewPanels = pagingScrollView

try to do (this will work only if you also add viewPanels as a subview to self.view):

[self.viewPanels addSubview:pagingScrollView];

I think that you should also modify or override the implementation of frameForPagingScrollView that comes with the Apple sample:

- (CGRect)frameForPagingScrollView {
  CGRect frame = [[UIScreen mainScreen] bounds];
  frame.origin.x -= PADDING;
  frame.size.width += (2 * PADDING);
  return frame;
}

as you see, here the frame is pretty hardcoded respect to the screen size; in your case the frame will be shorter, so you should change the height also.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜