uikit

In iOS, can a UIButton be added by alloc and initWithFrame?

做~自己de王妃 提交于 2019-12-25 05:15:02
问题 A button can be added by: UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; myButton.frame = CGRectMake(100, 100, 160, 50); [myButton setTitle:@"click me" forState:UIControlStateNormal]; [self.view addSubview:myButton]; but can we go with the initWithFrame method: UIButton *myButton2 = [[UIButton alloc] initWithFrame:CGRectMake(100, 300, 160, 50)]; //myButton2.buttonType = UIButtonTypeRoundedRect; myButton2.titleLabel.text = @"click me"; [self.view addSubview:myButton2];

UISegmentedControl - how to toggle between 2 UITableViews

三世轮回 提交于 2019-12-25 04:56:04
问题 I have a tab bar based application. What is the best way to toggle between 2 different UITableView views? Should I use a wrapper view and add those 2 views to it and depending on which segment was chosen I will show the correct view? Using only one tableView will not work because the layout is different between those 2 tableviews. Thanks 回答1: I usually take a different approach: I prefer to use different dataSources for a single instance of tableView and then switching between them (usually

How to get all UIkit Accordions open on load with ReactJS and UIKit?

扶醉桌前 提交于 2019-12-25 04:12:17
问题 I'm building a ReactJS app and using UIkit I'm using the accordion component and I want all of the accordions expanded on page load. I tried to using this piece of code: UIkit.on('afterready.uk.dom', function() { var accordion = UIkit.accordion(UIkit.$('#my-accordion'), {collapse:false, showfirst: false}); accordion.find('[data-wrapper]').each(function () { accordion.toggleItem(UIkit.$(this), true, false); // animated true and collapse false }); }); but I get an error on "UIkit.on", it seems

How should correctly look the simple game architecture?

梦想与她 提交于 2019-12-25 03:54:23
问题 Currently, I'm trying to build a game with UIkit that consists of the three MVCs (for now): main application delegate class (with UINavigationController property), Menu class (UIViewController with xib file) and game content class (also UIViewController with xib file). Obviously, the game needs methods for loading the game state, preparing to play, pausing the game and saving the game state. IMHO, these methods belong to game content MVC, so I put them there. Now, everything is clear when the

How do you animate the resizing of a tableView without its rows/subviews getting clipped?

跟風遠走 提交于 2019-12-25 03:39:13
问题 EDIT: I originally asked this question in regards to general view resizing, but I realize now that it's something much more specific to tableViews. Say that a tableView originally has a frame of (0 0, 320 460), i.e., it fills an entire iPhone screen. In order to resize the tableView's height and animate the resize, I map the following code to a button: [UIView beginAnimations:@"Animation" context:nil]; [UIView setAnimationDuration:3]; CGRect rect = self.table.bounds; rect.size = CGSizeMake

UIResponder Delays

安稳与你 提交于 2019-12-25 02:53:53
问题 I have a UIView subclass that overrides UIResponder's touchesMoved: message. I've noticed that when I swipe my finger very quickly across the UIView, my touchesMoved: message only gets called every so often and not constantly getting messaged. Any ideas? Thanks. 回答1: According to Apple Developer Technical Support this is by design. 来源: https://stackoverflow.com/questions/2679532/uiresponder-delays

presentModalViewController not working properly

时间秒杀一切 提交于 2019-12-25 02:47:57
问题 I have 3 views. I want to do the following: A presents B modally A dismisses B A presents C modally I have setup a delegate pattern where A is B's delegate. This is how I am presenting and dismissing in B: [delegate dismissB]; //this is just [self dismissModalViewControllerAnimated:NO] [delegate presentC]; //this is just [self presentModalViewController:c animated:NO]; For some reason my app crashes when I execute this code with no debugger results (I have NSZombieEnabled). When I comment out

Flip the Image when saving out to disk

与世无争的帅哥 提交于 2019-12-25 02:47:20
问题 I am currently using the following code to write a CGContext to a PNG on disk: CGImageRef image = CGBitmapContextCreateImage(context); UIImage *myImage = [UIImage imageWithCGImage:image]; NSData *data = UIImagePNGRepresentation(myImage); [data writeToFile:path atomically:YES]; I found that the orientation of the resultant file is flipped from the way it appears on the screen(on an iPhone). What is the best way to flip this image on save so that when I later load the image it will be up right?

Tilt image with UIKit

独自空忆成欢 提交于 2019-12-25 01:53:06
问题 I want to one board for dama game.. can we tilt the whole board and also show the checkers big to near and small to far.. Like see in attached image.. How to make like that .? please help me.. 回答1: You want to do a perspective transform on the image or view. Here's a SO answer that might help you get started: How do I apply a perspective transform to a UIView? 来源: https://stackoverflow.com/questions/7105870/tilt-image-with-uikit

didSelectRowAtIndexPath not working on sdk 3.0

為{幸葍}努か 提交于 2019-12-25 01:26:02
问题 I was working on an app in SDK 2.x and everything was working fine, but now I have updated my SDK to 3.0 and found: didSelectRowAtIndexPath of tableview is not working. Anyone know why this is happening? 回答1: The Table View Programming Guide says: "You can control whether rows are selectable when the table view is in editing mode by setting the allowsSelectionDuringEditing property of UITableView. In addition, beginning with iPhone OS 3.0, you can control whether cells are selectable when