addsubview

viewWithTag and addSubview

旧巷老猫 提交于 2019-12-23 16:47:18
问题 I am trying to reuse the label by making a call to viewWithTag when I press the UIButton. The code looks ok when it is executed the first time, but is it leaking on executing it multiple times due to line 7? Also is it just better to remove the label from the superview, alloc and addSubview instead of using viewWithTag? 1. UILabel *label = (UILabel *)[self.view viewWithTag:100]; 2. if(label == nil) { 3. label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 20, 20)] autorelease]; 4. label

Add a UITableView to an existing ViewController

ε祈祈猫儿з 提交于 2019-12-23 16:32:27
问题 I'm trying to add a UITableView to an existing UIViewController programmatically. My run.h file has this: @interface runTests : UIViewController <UINavigationControllerDelegate,UITextFieldDelegate,UIAlertViewDelegate,UITableViewDelegate,UITableViewDataSource> {NSTimer *Timer;} @property (strong, nonatomic) UITableView *tableView; My app runs through a speed test and at the end of the test I'm trying to add a TableView to the View. At the moment I have this: -(void)addSpeedTable { self

UIPageViewController Traps All UITapGestureRecognizer Events

时光总嘲笑我的痴心妄想 提交于 2019-12-21 16:58:38
问题 It's been a long day at the keyboard so I'm reaching out :-) I have a UIPageViewController in a typical implementation that basically follows Apple's standard template. I am trying to add an overlay that will allow the user to do things like touch a button to jump to certain pages or dismiss the view controller to go to another part of the app. My problem is that the UIPageViewController is trapping all events from my overlay subview and I am struggling to find a workable solution. Here's

Difference between addSubview and insertSubview in UIView class

社会主义新天地 提交于 2019-12-17 10:20:13
问题 What is the difference between addSubview and insertSubView methods when a view is added programmatically? 回答1: The only difference is in where the view is added: whether it is the frontmost view ( addSubview: ), or it is before the 5th subview, ( insertSubview:atIndex: ) or if it is immediately behind another subview ( insertSubview:aboveSubview: ). 回答2: Using insertSubView: you can specify the index, which determines z-order of views. A view with a higher index lies above those with lower

Loading xib crashes app

自作多情 提交于 2019-12-14 03:22:11
问题 Hello all I am having a issue with showing a xib file from the main file not sure why this is happening with some of the xib files and not others. if(segment == @"1"){ Results1 *myView1 = [[Results1 alloc]initWithNibName:@"Results1" bundle:nil]; [self.view addSubview:myView1.view]; }else if(segment == @"2"){ Results2 *myView2 = [[Results2 alloc]initWithNibName:@"Results2" bundle:nil]; [self.view addSubview:myView2.view]; }else if(segment ==@"3"){ Results3 *myView3 = [[Results3 alloc

How to Auto Layout with existing Custom View with multiple subviews in iOS 6

女生的网名这么多〃 提交于 2019-12-13 07:04:35
问题 I am trying to make the Layout using constraints, but I have many custom controls with internal nested Subviews. And I am adding the constraints to the top view (CustomView) but its not lay-outing the subviews properly. Ex. I have TextFieldWithLabel class which shows the Label on top and below that a UITextField I am creating the instance of TextFieldWithLabel and adding to super view with constraints. But its not showing the results as expected. though its visible but not placed where I

Adding UILabels and UIImageViews to UIScrollView programmatically

北战南征 提交于 2019-12-12 19:50:52
问题 I know this question is on here a lot, but I still can't seem to get this to work. I'm probably not initiating the view correctly or something... Anyway, I'm trying to add several labels and images to a UIScrollView programmatically. Here is my code for my .h file: #import <UIKit/UIKit.h> @interface DOR_HelpViewController : UIViewController <UIScrollViewDelegate> { IBOutlet UIScrollView *scrollView; } @property (nonatomic, retain) IBOutlet UIScrollView *scrollView; @end And my .m file:

iOS 6.0- UIAlertView failed to addSubview. Works fine in lower version

感情迁移 提交于 2019-12-12 02:32:14
问题 This is my code to show the table view inside alert view. Its working perfectly in iOS 5.1. But in iOS 6.0 it doesnt show the table view inside alert view. UIAlertTableView.h #import <UIKit/UIKit.h> @class UIAlertView; @interface UIAlertTableView : UIAlertView { // The Alert View to decorate UIAlertView *alertView; // The Table View to display UITableView *tableView; // Height of the table int tableHeight; // Space the Table requires (incl. padding) int tableExtHeight; id

When adding a sub view the view does not resize if the app is in landscape mode

让人想犯罪 __ 提交于 2019-12-11 13:30:00
问题 I have a view that has been created in Interface Builder and configured to resize according to the orientation. If the view is created and added to the display while the application is in portrait mode everything works perfectly. I can then rotate the device/simulator and the view resizes as I would expect. But, if the view is added when the app is in landscape mode it does not resize correctly. The view is created and sized as if the app is still in portrait mode. The view is added with the

How can I push a new View Controller from a button within a subView (another View Controller) in Storyboard

不打扰是莪最后的温柔 提交于 2019-12-11 08:24:17
问题 Wow, I gave a big thought on the question! So I have a view Controller called "ContentView" within another view Controller (Main VC). The Main VC has a Navigation Controller which was created using Storyboards. And the contentView loads 3 different view controllers (vc1, vc2 and vc3) depending on the options that a Segmented Control has. So the question now is: How can I load a new View Controller from the button within one of the subviews (vc2) that will appear once the user selects the