subview

How can I addSubview to UIButton in Interface Builder

て烟熏妆下的殇ゞ 提交于 2019-12-10 00:54:06
问题 Like I said, I add a UIButton in Interface Builder, I want add a UILabel、UIImageView as the button's subviews, but I can't add any object on it in IB. IS anybody know how to do this? Thank you very much. I can use code to achieve that, but I want achieve it in IB, so I can use it in any class I want. 回答1: I have done this before by adding a UIView (instead of the UIButton) then add the UIButton and UILabel to the UIView. The tap from the UIButton still works and you have a label too. You can

UITableView as a subview?

拜拜、爱过 提交于 2019-12-09 19:26:01
问题 Is this possible? I just want a small table in my current view... here is what I'm trying to do: .h file #import <UIKit/UIKit.h> @interface IngredientsRootView : UIViewController <UITableViewDelegate, UITableViewDataSource> { UITableView *ingredientsTable; } @property (nonatomic, retain) UITableView *ingredientsTable; @end .m file I have delegate and data source methods and this code: ingredientsTable = [[UITableView alloc] initWithFrame:CGRectMake(10, 10, 300, 300) style

I would like a “drawing popover” appearing by clicking in a tableviewcell?

我的梦境 提交于 2019-12-08 12:59:35
问题 I would like to have a popover with a signature "drawing" when I click in a tableviewcell. Like this picture : So here is my code : - (void)didSelectWithTableView:(UITableView *)tableView controller:(UIViewController *)controller { red = 0.0/255.0; green = 0.0/255.0; blue = 0.0/255.0; brush = 2.0; opacity = 1.0; viewController = [[UIViewController alloc] init]; mainImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, viewController.view.frame.size.width, viewController.view.frame.size

App crash when pressing a button in a subview

我只是一个虾纸丫 提交于 2019-12-08 06:40:07
问题 I've a big problem with a scrollView . I have this code and when i press a button that is in the xib file of "registerView" then the app crashes: MainViewController.m: ViewDidLoad: UIScrollView* scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; scrollView.backgroundColor = [UIColor whiteColor]; scrollView.scrollEnabled = YES; scrollView.pagingEnabled = NO; scrollView.showsVerticalScrollIndicator = YES; scrollView

UIPageViewController changes size?

柔情痞子 提交于 2019-12-08 02:12:13
问题 I'm using the Page-Based Application template in Xcode 4 to load pages of a PDF and create a UITextView over hidden text boxes so the user can write notes. So far I have it all working, but when I add the UITextView, it's in the wrong place in landscape mode (showing 2 pages). // ModelController.m - (id)init { self = [super init]; if (self) { NSString *pathToPdfDoc = [[NSBundle mainBundle] pathForResource:@"My PDF File" ofType:@"pdf"]; NSURL *pdfUrl = [NSURL fileURLWithPath:pathToPdfDoc];

Implementing UIPageViewController's logic as a subview to a UIViewController in Swift

孤街醉人 提交于 2019-12-07 21:50:33
问题 I have to implement a UIPageViewController as a subview to my UIViewController. The UIPageViewController has some logic and other ViewControllers inside. My question is how to connect these two pieces of code below. So this is my main UIViewController code: class MyMainViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } } and my UIPageViewController code, which implements an endless

Subviews of UITableViewCell are not visible while reordering

吃可爱长大的小学妹 提交于 2019-12-07 08:50:39
问题 When I reorder my UITableViewCells, the Subviews of the Cell are not visible while dragging...I get always the same result, whether I add the Subviews programmatically in a UITableViewCell Subclass or in Storyboard... Is there a possibility to see the real UITableViewCell with Subviews while dragging? 回答1: Ok I found a solution by my self... For some reason the mysterious reordering animation from Apple cant capture simple UIViews, but with UIImageViews, UIButtons and UILabels as Subviews of

How to give this picker view a datasource

落爺英雄遲暮 提交于 2019-12-07 05:08:20
问题 Here I am adding a pickerview programaticly - (void)viewDidLoad { [super viewDidLoad]; CGRect pickerFrame = CGRectMake(0,280,321,200); UIPickerView *myPickerView = [[UIPickerView alloc] init]; //Not sure if this is the proper allocation/initialization procedure //Set up the picker view as you need it //Set up the display frame myPickerView.frame = pickerFrame; //I recommend using IB just to get the proper width/height dimensions //Add the picker to the view [self.view addSubview:myPickerView]

UISlider won't work when it becomes a subview of a UIView other self.view

我怕爱的太早我们不能终老 提交于 2019-12-07 05:04:46
问题 When I add my slider as subview of any view besides self.view it does not work (doesn't slide) but it works fine when it is a subview of self.view. You can see it on the other views besides self.view but it doesn't work. Here is my code: alphaSlider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 90, 10)]; [alphaSlider setMinimumValue:0.01]; [alphaSlider setMaximumValue:1]; [alphaSlider setValue:0.5]; [alphaSlider setUserInteractionEnabled:YES]; [alphaSlider addTarget:self action:@selector

setNeedsDisplay does not trigger drawRect in subviews as expected

余生颓废 提交于 2019-12-07 03:09:43
问题 I'm struggling with setNeedsDisplay . I thought it was supposed to trigger calls of drawRect: for the view for which it is called and the hierarchy below that if it's within the view's bounds, but I'm not finding that to be the case. Here is my setup: From the application delegate, I create a view whose size is a square that covers essentially the whole screen real estate. This view is called TrollCalendarView . There is not much that happens with TrollCalendarView except for a rotation