uilabel

parsing txt from array to UILabel

匆匆过客 提交于 2019-12-13 03:54:01
问题 I'm actually starting to loose the will to live, this piece of code is driving me nuts! I'm trying to get the content of mathspractice.txt into *myLabel I'm using an array which is: -(void)loadText { NSArray *wordListArray = [[NSArray alloc] initWithArray: [[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@”mathspractice” ofType:@”txt”] encoding:NSMacOSRomanStringEncoding error:NULL] componentsSeparatedByString:@”\n”]]; self.theMathsPractice = wordListArray;

UIButton does not resize height correctly with custom font when sizeToFit is called

自作多情 提交于 2019-12-13 02:59:00
问题 I'm attempting to create a UIButton using a custom font. I set the titleLabel's font and then set my text, then call sizeToFit . Unfortunately, it resizes the height to a couple of pixels too small and shaves off part of each capital letter. The button's titleLabel has a smaller height than the size of the button itself, but setting its frame manually after calling sizeToFit isn't doing anything for me. I noticed the same behavior from a plain UILabel , except when I manually set the frame to

UILabel inside UITableViewCell `sizeToFit` not working inside cell with AutoLayout

旧巷老猫 提交于 2019-12-13 02:43:45
问题 I've been trying to resolve this issue for almost a day. So the dot should align with the UILabel next to it. The thing is, the second label will sometimes become 2 lines when fill with the right content. The dot has to be align with the first line of the UILabel , whether it has 1 or two lines. I tried to call sizeToFit() at runtime when the cell is updated. Seems no effect. I read Vertically align text to top within a UILabel thread. I simulate if sizeToFit() (Editor -> Size to fit content)

Get correct text height for iOS 7 in iPhone SDK

瘦欲@ 提交于 2019-12-13 02:28:33
问题 I need to get text height and grow cell's height depending upon text height which increase or decrease dynamically. I now successfully getting correct height of text for iOS 6 and prior but I am not able to get correct height iOS 7 and later. I googled and found many solution but this doesn't worked. You can see attached Image of same cell and see difference in iOS 7 text is truncating and in iOS 6 its showing correct size. I used UILabel . Follow my code of what exactly I am doing. Kindly

How to know the width of last line of label?

与世无争的帅哥 提交于 2019-12-13 01:27:47
问题 In my app I have a label which text came from the server so I don't Know its width, and at the end of this label directly there should be an UIImage. My problem is: I don't know how to position the image because of the non static width of the label text. To be more clear, this is a snapshot form the design and how should it be: Any suggestion to solve this problem please? 回答1: Set the text of the UILabel Get the width of this UILabel with yourUILabel .frame.width Set the x coordinate of your

UIStepper not updating the Corresponding Label

三世轮回 提交于 2019-12-13 00:33:56
问题 I have a UIStepper control that i created programmaticly in my UITableViewCell . I also created a UILabel programmaticly for the cell. whats happening is that the stepper when pressed is accessing a UILabel located in a different cell i.e index path 1 and not 0. here is the code. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ ... //---------UIStepper Creation-------------------// stepper = [[UIStepper alloc]init]; [stepper setFrame

UITextView how to cut off text

六眼飞鱼酱① 提交于 2019-12-13 00:18:06
问题 I have a UITextView that is displaying a facebook status loaded from Facebook Connect. I'm trying to make it so that the UITextView is just creating a preview of the text. I want it to look like it does when there is too much text for a UILabel. It would be something like "There is too much text..." with the dots but UITextViews don't do that. Does anybody know how to get it to work? 回答1: Write a separate method that counts how many letters there are in the string and if there are more than

How detect time settings of device?

六月ゝ 毕业季﹏ 提交于 2019-12-12 22:00:22
问题 I have an application in which i have made a alarm clock. In my application problem is that when device date and time settings changed then text of label of alarm also changed. For example if time settings is set as 24 hours then in my label 's text don't show am and pm in last while when change settings as 12 hours then in label's text show am and pm. How detect that what is settings of date and time and how apply validation on label's text that whatever settings always display in am and pm

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:

Different UIFont sizes for different iOS devices in Swift

主宰稳场 提交于 2019-12-12 18:57:43
问题 I'm developing swift based iOS application for iPhone family. My application supports all devices start from iPhone 4s to iPhone X. Labels appears bigger in smaller devices like iPhone 4s as I added bigger font size for high end devices. Can someone help me on how to scale the font according to device. I tried size classes with compact/regular width and compact/regular height but none of them helped me. Your help is very much appreciated 回答1: You can try label hight according to view in