uikit

How to create an timeline on iPhone

人盡茶涼 提交于 2020-01-01 18:04:12
问题 I am trying to create an inifite timeline in my iPhone app to scroll through time. I think I am going to use a UIScrollView to do that but I am not sure how to do that. Am I supposed to create a reusable queue of views from scratch with views containing the days/months/years and reuse them when they go out of the screen ? (I have in mind the reusable cells from the tableviews). Maybe there is a better way to do that ? Thanks for your help ! 回答1: As far as I know, UIScrollView doesn't have

Adding a QuadCurve to UIBezierPath

ぃ、小莉子 提交于 2020-01-01 17:05:48
问题 I am doing a drawing app and I am trying to smooth the line which I draw with finger.For this purpose I am using "quadCurveToPoint" function. But, I am not getting it right. Below is my code: - (void) drawRect:(CGRect)rect { [path stroke]; } - (id) initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) self.multipleTouchEnabled = NO; path = [UIBezierPath bezierPath]; path.lineWidth = IS_IPAD? 2.0f : 1.0f; return self; } - (void) touchesBegan:(NSSet *) touches withEvent:(UIEvent

Come back to a specific View in SwiftUI (popToViewController)

久未见 提交于 2020-01-01 16:35:38
问题 Is it possible in SwiftUI to come back to a specific view? Let's say I have three views this way: struct View1: View { var body: some View { NavigationView { VStack { NavigationLink(destination: View2()) { Text("Navigate to View2") } .navigationBarTitle("View1") } } } } struct View2: View { var body: some View { NavigationLink(destination: View3()) { Text("Navigate to View3") } .navigationBarTitle("View2") } } struct View3: View { var body: some View { Text("View3!") } } #if DEBUG struct

Come back to a specific View in SwiftUI (popToViewController)

不问归期 提交于 2020-01-01 16:33:16
问题 Is it possible in SwiftUI to come back to a specific view? Let's say I have three views this way: struct View1: View { var body: some View { NavigationView { VStack { NavigationLink(destination: View2()) { Text("Navigate to View2") } .navigationBarTitle("View1") } } } } struct View2: View { var body: some View { NavigationLink(destination: View3()) { Text("Navigate to View3") } .navigationBarTitle("View2") } } struct View3: View { var body: some View { Text("View3!") } } #if DEBUG struct

iOS drawInRect:attributes perform text truncation with multiple lines

帅比萌擦擦* 提交于 2020-01-01 12:36:09
问题 How can I draw a long text string in a rect with tail truncation? I tried to use drawInRect:withAttributes: with NSLineBreakByTruncatingTail paragraph style, but it always renders text on a single line. It only renders multi-line text with NSLineBreakByWordWrapping and NSLineBreakByCharWrapping break modes and when using this option there is no truncation. Is there any property that I need to set on the paragraph style in order to make this happen? Or is this simply no longer supported, in

How to disable letter characters in UITextField?

荒凉一梦 提交于 2020-01-01 08:55:49
问题 In my application i need to allow users input only numbers. How can i allow UITextField to receive only numbers from user? 回答1: The characters in this examples are allowed, so if you dont want the user to use a character, exclude it from myCharSet . - (BOOL)textField:(UITextField *)theTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSCharacterSet *myCharSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"]; for (int i = 0; i <

iOS 7: UIWebView crashes because of range exception

落爺英雄遲暮 提交于 2020-01-01 05:50:22
问题 I'm currently building an App that uses the krpano viewer, which is a Panorama Viewer built with JavaScript. I'm loading this Panorama viewer in a UIWebView with local images that are saved on the iPad. But after using the Panorama viewer for a while, I get this error and the app crashes: Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[WebCoreSharedBufferData getBytes:range:]: range {0, 4000} exceeds data length 0' *** First throw call stack: (0x2e213f53

Swift Lazy and Optional properties

大憨熊 提交于 2020-01-01 05:45:14
问题 What is the difference between a Lazy or Optional property in Swift? For example, if someone is building a navigation bar that comes in from the side, I think that should all be within one UIViewController . The user might never open the menu but sometimes they will. var menu: NavigationBar? lazy var menu: NavigationBar = NavigationBar.initialize() Both of the optional I think are good code, because they don't create the view unless its needed. I understand Optional means there might be a

Swift, custom UITableViewCell with UIImageView. Need to resize cell to image height

自闭症网瘾萝莉.ら 提交于 2020-01-01 03:18:07
问题 I'am trying to make app, that will show images in table view. I have custom cell with image view. It only must download image data from url: @IBOutlet weak var tweetImage: UIImageView! var imageData : MediaItem? { didSet { updateUI() }} func updateUI(){ tweetImage.image = nil if let url = imageData?.url { if let data = NSData(contentsOfURL: url) { tweetImage.image = UIImage(data: data) } } } I need to get the cell height was changed after the download. It must be equal to the height of the

Setting iOS background/lockscreen image programmatically?

别等时光非礼了梦想. 提交于 2020-01-01 02:47:08
问题 I'd like to be able to set the lockscreen background image programmatically. I'm aware that this is only possible for jailbroken iOS devices. Here are some things that I've tried: Place a LockBackground.png in /private/var/mobile/Library/SpringBoard/. This works but requires a hard respring. notify_post("com.apple.language.changed"); doesn't work for a soft respring. Use class-dump to dump private methods of UIKit. UIKit in 4.2 used to have a method called + (void)setDesktopImageData:(id)fp8;