w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Autolayout: Custom UIView height constraint with UIWebViews
try this code snippet. -(void)webViewDidFinishLoad:(UIWebView *)webView { NSString *webHeight = [self.lblDetail stringByEvaluatingJavaScriptFromString:@"document.height"]; NSLog(@"height: %@", webHeight); self.webViewHeightConstraint.constant = [webHeight intValue]; }

Categories : IOS

How to set UIScrollView content size for AutoLayout enabled UIVIew
set contensize : if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone ) { // set your requirement size [yourscrollview setContentSize:CGSizeMake(320, 600)]; } else { // set your requirement size [yourscrollview setContentSize:CGSizeMake(768, 1100)]; }

Categories : Iphone

is it possible to segue from a UITableViewCell on a UIView to another view
performSegueWithIdentifier: is a method of the UIViewController class. You cannot call it on a UITableView instance. Make your view controller implement the UITableViewDelegate protocol and set it as the delegate for the UITableView. Another option is that you don't use segues. In the same delegate method do: OtherViewController ov = [[OtherViewController alloc] init<<some initializer>>]; // Or in case of storyboard: OtherViewController ov = [self.storyboard instantiateViewControllerWithIdentifier:@"ovidentifier"]; // push view controller [self.navigationController pushViewController:ov animated:YES]; If the delegate object is different from the view controller, then the easiest solution is to add a weak property to the delegate's class that keeps a reference to the viewCo

Categories : IOS

Autolayout, pinning a view to sibling of zero height
So, there's a constraint in my _commentView with the following format: @"V:|-(8.0)-[_usernameLabel(30)]-[_contentLabel]|" _usernameLabel and _contentLabel are both subviews of _commentView. This appears to be the offending constraint. If I remove the final pipe, the _commentView resizes as expected. Unfortunately, without the final pipe, _contentLabel does not expand to reach the bottom of its superview. But that's a separate question.

Categories : IOS

how calculate UITableViewCell height seeing content
Because the content is dynamic, one way to do it is to calculate the height of the cell ahead of heightForRowAtIndexPath (or equivalent method) being called and store those values in an array. -(void)calculateCellHeights:(NSArray *)contentArray { self.heightArray = [[NSMutableArray alloc] initWithCapacity: contentArray.count]; for( MyCellContent *content in contentArray ) { CGFloat totalHeight = 0; totalHeight += content.image.size.height; CGSize titleSize = [content.title sizeWithFont:self.myTitleFont]; totalHeight += titleSize.height; CGSize textContentSize = [content.textContent sizeWithFont:self.myTextContentFont]; totalHeight += textContentSize.height; [self.heightArray addObject:@(totalHeight)]; } } -(CGFloat)

Categories : IOS

Autolayout height equal to MAX(multiple view heights)
You need one constraint for each subview (button), specifying that the container's height should be greater than or equal to the subview's height. Give that constraint a high priority, like UILayoutPriorityRequired (which is the default anyway). Then add one more constraint on the container's height, specifying that it should have a height equal to zero. Give that constraint a low priority, like UILayoutPriorityLow. Since auto layout tries to minimize the error of unsatisfied constraints, it will make the container as short as possible while still satisfying all higher-priority constraints. I have put an example in this gist. It produces this result: The blue views have fixed heights. The tan view is the superview of the blue views and its height is constrained as I described abo

Categories : IOS

Adjust height UITableViewCell in viewDidLoad to content
The height a particular row is controlled by the method tableView:heightForRowAtIndexPath: of you UITableViewDelegate. You cannot manually change the size of a cell, it is resized by the TableView to the cell size (tableView width and row height) when it layouts its subviews. On another point, what it the point of this line: newSize.size.height = UI_USER_INTERFACE_IDIOM() ? 48 : 48; It sets the same value and compares the idiom to 0 instead of iPhone or iPad (one of them might have the value 0, so the check might be working for now, but using the constants is better).

Categories : IOS

Resizing UIView with autolayout when placed below a fixed size UIView
Try the following, as per this answer. Make sure you call layoutIfNeeded on the superview: [UIView animateWithDuration:ANIMATION_DURATION delay:ANIMATION_DELAY options:UIViewAnimationOptionCurveEaseOut animations:^{ heightConstraint.constant += offset.y; [self.view layoutIfNeeded]; } completion:nil];

Categories : IOS

How can I center a UIView programmatically on top of an existing UIView using Autolayout?
Try this: NSLayoutConstraint *xCenterConstraint = [NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:view2 attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]; [superview addConstraint:xCenterConstraint]; NSLayoutConstraint *yCenterConstraint = [NSLayoutConstraint constraintWithItem:view1 attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:view2 attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]; [superview addConstraint:yCenterConstraint]; Updated for Swift: let xCenterConstraint = NSLayoutConstraint(item: view1, attribute: .CenterX, relatedBy: .Equal, toItem: view2, attribute: .CenterX, multiplier: 1, constant: 0) superview.addConstraint(xCenterConstraint) let yCenterConst

Categories : Iphone

UILabel in nested view in UIScrollView gets compressed under autolayout even with 1000 content compression resistance
I had the same issue. There seems to be a bug with apple, so multiline text requires a two-pass approach to layout correct and it all relies on the property preferredMaxLayoutWidth. I ended up adding these two methods to the ScrollViewController: - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; [self performSelectorOnMainThread:@selector(adjustScrollContentSizeOnMainThread) withObject:nil waitUntilDone:NO]; } - (void)adjustScrollContentSizeOnMainThread { self.myLabel.preferredMaxLayoutWidth = self.myLabel.bounds.size.width; } I based my solution on this answer: http://stackoverflow.com/a/13616052/2828256

Categories : IOS

How to add fixed width and height constraints between windows content view and NSViewControllers View
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { self.rootVC = [[VZMConversationViewController alloc] initWithNibName:@"VZMConversationViewController" bundle:[NSBundle mainBundle]]; NSView *rootView=self.rootVC.view; [rootView setTranslatesAutoresizingMaskIntoConstraints:NO]; [[[self window] contentView] addSubview:rootView]; [[[self window] contentView] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[rootView]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(rootView)]]; [[[self window] contentView] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[rootView]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(rootView)]]; } This fixed the problem

Categories : Osx

UITableViewCell autolayout
This problem is generated because Your UITableView Reuse Cell instant of create new one. I give you some suggestion that may be helpful for you. 1) add UIView in between - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { /// Your code; } return cell; } 1) Add Your UIView to cell.contentView. EDITED: Before You follow my Edited Answer i want to tell you that following code is bad for memory management because it will create new cell for each rows of UITableView, so be careful for it. But it is better for if UITableView Have Limited row about (50-

Categories : Iphone

UITableViewCell bad performance with AutoLayout
It is true that Auto Layout can present a performance hit. However, for most cases it is not really noticeable. There are some edge cases with complicated layouts where getting rid of it will make a meaningful difference, but that's not really the issue here. I don't have a good explanation why the app is behaving the way it is, but at least I have a solution: Don't do table view updates if the table view is not on screen. This results in this weird behavior. In order to this, you can e.g. check for self.tableview.window != nil in the delegate methods of the fetched results controller. Then you just need to add a [self.tableview reloadData] to viewWillAppear so that the table view updates its data before coming on screen. Hope that helps. And please, if somebody has a good explanation f

Categories : Iphone

Have UITableViewCell resize itself with autolayout
As you are loading the individual cells, after you fill the labels, but before you load the instance of the cell, check the label height. Something like: cell.frame.size.height If the height is large enough that you know the label has wrapped to two lines, then increase the height of the cell you are about to load.

Categories : IOS

Autolayout+UIView+Its subview
We need to use the following code in order to remove constraint that has for the sub-view and last UIButton: [view_object removeConstraint:constraint_object];.After that we have to add constraint to the view and your first button.There are many ways to add constraint but as per your requirement, this is the code [view_object addConstraint:[NSLayoutConstraint constraintWithItem:sub-view_object attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:button_object attribute:NSLayoutAttributeBottom multiplier:1.0 constant:10]];.

Categories : IOS

iOS + Autolayout: UITableViewCell label + textfield width with rotation
You could try this answer it is a similar problem you are having and involves working with constraints : AutoLayout to keep view sizes proportional

Categories : Iphone

UIView not obeying autolayout constraints in UIScrollView
UIScrollView automatically shrinks to fit the views inside it. You need to set the width absolutely somewhere. Recommended tactic: Completely fixiate the scrollview inside its parent-view using constraints (leading, trailing, top, bottom). Create a UIView inside the UIScrollView and put everything you need inside it. Set the constraints so that the UIView will act as a content-view (this means it is big enough to include all elements). Use intrinsic content-size, shrink-resistance and chaining of elements with constraints a lot. The resulting layout must be well-defined and unique (this means if you were to remove all constraints to the outside, the layout would still work). Connect the bounds of the UIView with their superview (which is the actual content-view of the UIScrollView, NOT

Categories : IOS

Get a height of content with Javascript , Mobile Web View
Using innerHeight you can get the height of the device that runs your web app. I found this answer here and i think this is what you need. Hope this helps,

Categories : Javascript

iOS - Autolayout not working for main UIView - (screenshots inside)
You should give the view a fixed width constraint and a fixed height constraint (from the menu, Editor --> PIN --> Width and likewise for height), then delete the horizontal and vertical space constraints (leaving the centerX and centerY constraints).

Categories : IOS

How to display google map in right half of the screen while left half of the screen contain list view
Use linear layout with horizontal orientation and put both your mapview and listview inside it , now give similar weight to them .May be that will work .for example give layout_weight 1 or 0.5 in both mapview and listview .

Categories : Android

Animate UIImageView from center to 20 points from the top of parent UIView using AutoLayout
I'm not really a master of NSLayoutConstraints, but either you should add the constraint to the logoImageView object or you should change the constraintWithItem: parameter because to me something looks strange right now. You're removing a constraint from the imageView, then adding a constraint to the self.view object which refers to self.view item

Categories : IOS

Subclassed UIView in UITableViewCell from NIB
You need to make a subclass of UITableViewCell. In your subclass's initWithCoder: method, after you've called [super initWithCoder:aDecoder], you can load the other nib and add its view as a subview of the cell (self).

Categories : IOS

Display a UIView within a UITableViewCell pragmatically
Instead of eventDrawer.bounds = eventCell.bounds; try eventDrawer.frame = eventCell.bounds; The bounds of a view are viewed from inside, so the origin will be 0, 0. However the frame of a view is relative to it's superview, so the origin can differ from 0, 0.

Categories : IOS

Custom UIView in UITableViewCell Issue
try to set the autoresizingMask for that view like... [_checkboxView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin]; ENJOY CODING.........

Categories : Iphone

UIView animation in UITableViewCell works only once
Your UITableViewCell will remember it's state from before. When it's put into the queue (when it scrolls out of view), it doesn't revert back to a pristine state. When you call your ZoomIn method, I think what's happening is that it's zooming in again, but you can't tell because it's already zoomed in. Try - before you zoom in, ensure that it's zoomed out. So in ViewWillAppear, to a quick "Reset" of the Cell, and then call zoomIn, and see if that fixes the issue.

Categories : IOS

Can not get touch event when UIView outside of UITableViewCell
no, "please select ownership" is a table view and added to another table view cell. "please select ownership" is a dropdown control which wrap via a table view, when click it, it will insert additional cells dynamically.

Categories : IOS

UITableViewCell viewWithTag get frame of UIView trouble
I don't understand your logic. cellForRowAtIndexPath is where you define the UIView so technical you have it. As the other user said, show us your code. Anyways, this is how I defined a custom UIButton in my tableview that shows up in every row. I am assuming you are trying to do something similar. Forget adding your UIView to storyboard. See if you can replicate it using this code. Of course change it to your UIView code. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *CellIdentifier = [NSString stringWithFormat:@"S%1dR%1d",indexPath.section,indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil) { cell = [[UITableViewCell alloc]initWithS

Categories : Iphone

Style UITableViewCell inside UIScrollView/UIView
Its a naming problem. in your method header you pass thisTableView as the tableView to use, but then you call [tableView dequeueReusableCellWithIdentifier]; to get a cell. It should generate an error, but probably there is another variable by that name, or a property? Anyways, if thats your verbatim code, theres your error.

Categories : IOS

UIView containing UIScrollView inside UITableViewCell's contentView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellId"] autorelease]; UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease]; UIScrollView *scrollView = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease]; scrollView.contentSize = CGSizeMake(2000, 100); [scrollView setPagingEnabled:YES]; [cell addSubview:view]; [view addSubview:scrollView]; return cell; } This just worked fine for me. This is how I'm initing the table view self.viewController = [[[ViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease]; Try to

Categories : IOS

Calling `[UIView -systemLayoutSizeFittingSize:]` on a UITableViewCell always fails
It is hard to say something concrete basing on your post because you didn't post constraints that you use. Apple Documentation: systemLayoutSizeFittingSize: Returns the size of the view that satisfies the constraints it holds. Maybe you created constraints that can be interpreted in the way the size of the cell is equal to (0,0). There is another way you can check the height of the cell with the text. You can put your text in the UITextView and then: UITextView textView; textView.text = @"l"; textView.font = [UIFont fontWithName:FONT_NAME size:FONT_SIZE]; //some code here // CGFloat cellHeight = textView.contentSize.height; It is important to set the text and font (and every other property that can cause the change of the height of the UITextView) of the UITextView before

Categories : IOS

How to adjust the height of a tableView Cell based on html content of the web-view inside it?
Create the webviews and load the contents first, make sure the height of the webview is zero After all the webview was loaded, set the TableView's Delegate and DataSource, modify the height of all the webviews. Override -(CGFloat)height...tableview indexPath.... As below { return eachWebviewInside.scrollview.contentSize.height;}

Categories : IOS

Set the height of a div to be half of whatever the width is
This is not possible with pure CSS. You have to use jQuery for it to generetate the new sizes. I've found this in SO: Using jQuery To Get Size of Viewport

Categories : Jquery

Custom UIVIew layoutSubviews causes an error when setting a transform (AutoLayout asks me to call super method even though I already am)
Well, this isn't really a full answer, but I wanted to document my fix since it does reveal a little more about the problem, and could possibly help someone out. So it turns out that the issue was somehow related to the interface builder (I think). I had this subclass of UIVIew described above being instantiated by the storyboard (by changing the class type of the root view in the view controller). I was also linking the subviews in the storyboard to IBOutlets in the view. Apparently that does some funny stuff, perhaps overriding or changing some of the default layout mechanisms. Once I pulled the view completely out of interface builder and instantiated and added everything manually in code, it worked fine.

Categories : IOS

How do I make self.view the full height of the view controller (occupies height of navigation bar and status bar as well)
I'm not sure if I totally follow what you want, but I think it's something along these lines: - (void) viewDidLoad { [super viewDidLoad] self.view.frame = [[UIScreen mainScreen] bounds]; // You may or may not want to reference [[UIDevice currentDevice] orientation], too // Other stuff, whatever you want to do... } Note, too, that you can turn-off auto-resize and constraints, if the problem you're having is related to those. In general, the view controller's view not-including the nav-bar, etc. isn't a good idea. If you're having trouble because of that, you might want to consider another design.

Categories : IOS

Setting UITableViewCell height and the cell's text label based on the text height
I think that the problem might be of adjusting the vertical alignment of the text in the UILabel instance. I think you should do the following inside cellForRowAtIndexPath: cell.infoLabel.text = _content[[indexPath row] * 2]; cell.infoLabel.numberOfLines = 0; [cell.infoLabel sizeToFit]; More details about it can be found in the following link: Vertical Alignment of UILabel Text Hope this helps! :)

Categories : IOS

Set height of toolbar using AutoLayout and support orientation
In this case what you want is to set the relative object as nil, and simply set the constant. Any view listed in your constraint must be at or below the view you add the constraint to in the view hierarchy.

Categories : Iphone

How to well adapt height and position of views in iOS without AutoLayout?
Try this: Xcode 4.5: How do I fix my text views so they display properly in portrait and landscape mode on an iPad? I think this could fix your problem and if you are using Storyboards it makes it less difficult.

Categories : Iphone

created a jquery tab content changer when tab content is increasing height due to inner content its over lapping to its bottom div
This happens because the wrapper of you content tabs .tab-container has height: 300px;. Put it to min-height: 300px; and should work fine. Test: JsFiddle

Categories : Jquery

Width and Height Equal to its superView using autolayout programmatically?
Why do you want to create a button with the same width and height of the scrollView? If what you want is to detect when the user tap inside the scrollView I suggest you to use UITapGestureRecognizer. UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionMethod:)]; [self.myScrollView setUserInteractionEnabled:YES]; [self.myScrollView tapRecognizer]; If you do this the scroll view will always recognize any taps on it independent of it's frame, location, etc.

Categories : IOS

How to make UITableView's height dynamic with autolayout feature?
This is with Xcode 4.6 and the iPhone, but I believe it will work in Xcode 5. 1)In Xcode click on you table view to select it. 2)In the Utilities pane (see picture 1) select the constraint for the table view height, click on the little gear icon and choose "Promote to user constraint". The icon un the right will change color from purple to blue (see picture 2) 3)In the view controller that displays the table view create an outlet to this constraint: @property (strong, nonatomic) IBOutlet NSLayoutConstraint *dynamicTVHeight; 4)Also put this code in the same view controller: - (void)viewWillAppear:(BOOL)animated { // just add this line to the end of this method or create it if it does not exist [self.tableView reloadData]; } -(void)viewDidLayoutSubviews { CGFloat hei

Categories : IOS



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.