UITextField我的应用程序中有一个应该只接收来自用户的数字输入.此数字输入应该表示货币(即只有两个小数位),当没有输入任何内容时,默认值为0.00.我还希望在最左边有一个"$"符号,数字右对齐,这样数字从右向左移动,如下所示:
例如,输入数字"1234.56".
1. 0.00美元.
2. 0.01美元.
3. 0.12美元.
4. 1.23美元.
5. $ 12.34.
6. 123.45美元.
7. 1,234.56美元.
8.等等......
我UITextField右对齐,以便它已经将数字从右边移到左边.但是,我需要在UITextField中放置"$",我希望将默认的0.00值修改为用户一次输入的数字.用户不必输入小数点,因为它应该已经在保持其位置的文本字段中.然后,我希望数字有一个","自动输入以分隔每三个数字.我希望应用程序执行此操作,因为用户正在输入数字,并且在输入所有内容后不会格式化.我该怎么做?我见过很多人都说我要使用,但是我想知道我如何结合使用它,以便它可以动态格式化数字文本,如上所述?NSNumberFormatterUITextField
我发现在StackOverflow上发布了以下问题:
但我想知道如何将其作为我问题的解决方案.
我有一个iOS应用程序,我将图像保存到我的照片文件夹到我的iPad.但是,我想要做的是使用自定义名称存储图像(例如,使用实际捕获图像时的日期和时间戳),以便将来检索它更容易.我目前存储图像的代码如下:
- (IBAction)imageCapture:(id)sender {
UIImage *myImage = [_imageView currentImage];
UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil);
}
Run Code Online (Sandbox Code Playgroud)
我可以存储我的图像,但是如何在存储图像之前命名图像(例如"082620131100am.png"?
在此先感谢所有回复的人
我正在研究一个我调用UITextFieldDelegate方法的应用程序:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { }
Run Code Online (Sandbox Code Playgroud)
我成功调用它,在方法中,我启用了一个特定的按钮.这也很好.但是,我面临的问题是,当按钮启用时,我无法在按钮粗体上创建标题.我在Interface Builder中设置了字体,我试图以编程方式加粗标题.以下是显示我正在做的相关代码:
if ([keys count] == [_tireName count]) {
[_doneButton setEnabled:YES];//this line works
[[_doneButton titleLabel] setFont:[UIFont boldSystemFontOfSize:28]];//this line does nothing
} else if ([keys count] < [_tireName count]){
[_doneButton setEnabled:NO];//this line works
[[_doneButton titleLabel] setFont:[UIFont systemFontOfSize:28]];//this line does nothing
}
Run Code Online (Sandbox Code Playgroud)
忽略"if"子句本身.当按钮启用时,我希望按钮上的文本为粗体,并且我希望按钮上的文本在禁用时为"正常".谁能看出我做错了什么?
在此先感谢所有回复的人.
我有一个基于导航的iPhone应用程序,我正在使用它,允许用户在地图上查看表格中的选择.我有一个注释,可以精确定位用户在地图上的选定位置.按照正常行为,如果用户单击注释,则会显示一个标注,其中包含有关该位置的详细信息.这里没问题.
我的问题是,一旦用户进入包含地图的屏幕,我希望标注自动从注释中显示,这样用户就不必点击注释就能看到有关位置的详细信息,但我不知道该怎么做.我在"MapViewController"类中有以下方法,其中执行了大量的地图显示工作:
- (void)viewDidLoad {
[super viewDidLoad];
MKCoordinateRegion region;
MKCoordinateSpan span;
NavButtonAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
userCoord = delegate.userLocation.coordinate;
region.center = userCoord;
span.latitudeDelta = 0.4;
span.longitudeDelta = 0.4;
region.span = span;
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
mapView.showsUserLocation = YES;
[mapView setRegion:region animated:YES];
RestaurantAnnotation *rAnnotation = [[RestaurantAnnotation alloc] init];
rAnnotation.title = restaurantObj.name;
rAnnotation.subtitle = restaurantObj.address;
rAnnotation.subtitle = [restaurantObj.address stringByAppendingFormat:@" %@", restaurantObj.hours];
rAnnotation.subtitle = [restaurantObj.address stringByAppendingFormat:@" %@", restaurantObj.phoneNumber];
CLLocationCoordinate2D newCoord = {restaurantObj.latitude, restaurantObj.longitude};
rAnnotation.coordinate = newCoord;
[mapView addAnnotation:rAnnotation];
}
Run Code Online (Sandbox Code Playgroud)
从上一个屏幕中的以下方法调用MapViewController: …
我有一个相当简单的问题.出于某种原因,我发现当我在Project Navigator中突出显示Xcode中的文件时,突出显示的文件是白色,而不是深黑色.我有办法改变这个吗?
这是一个正在发生的事情的例子:
如您所见,选中的文件突出显示为白色,我希望它像以前一样是黑色的.这可能吗?
我是一名学习Objective-C的新iPhone开发人员,我正在尝试动态计算用户纬度/经度坐标与SQLite表中纬度/经度坐标之间的距离.我知道我们可以使用CLLocations方法:
(CLLocationDistance)distanceFromLocation:(const CLLocation *)location
Run Code Online (Sandbox Code Playgroud)
要做到这一点,但鉴于我拥有的数据,我不确定如何使用它.如何使用上述方法使用成对的纬度/经度坐标,考虑到上述方法只处理CLLocation类型的位置对象?任何人都可以给我一个简单的例子,说明如何使用这对方法使用两对纬度/经度坐标?
我正在尝试在JSP中部署动态Web应用程序,并使用Spring和Hibernate框架在多个Java类和包中进行部署.我使用tomcat6作为我的网络服务器,MySQL作为我的数据库后端.不幸的是,当我尝试部署我的应用程序时,我得到以下堆栈跟踪:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet hadithSearcher threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Unknown Source)
root cause
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hadithController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private au.com.bandaconsulting.hadith.searcher.web.service.SearchService au.com.bandaconsulting.hadith.searcher.web.controller.HadithController.searchService; nested exception is java.lang.NoClassDefFoundError: au/com/bandaconsulting/databeans/IndexConfig
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1055)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) …Run Code Online (Sandbox Code Playgroud) 我正在iOS中的应用程序上工作,我有一个NSDateFormatter对象,如下所示:
NSDate *today = [NSDate date];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"EEE, MMM. dd"];
NSString *dateString = [dateFormat stringFromDate:today];
NSLog(@"%@", dateString);
Run Code Online (Sandbox Code Playgroud)
我的输出是:12月10日星期二,我想显示:TUE,12月10日.
我的问题是,星期几只有首字母大写,而不是整天(即我得到"星期二",我想显示"TUE").月份的格式很好(即"Dec"我很满意).我已经检查了日期格式的规格,遗憾的是,使用NSDateFormatter类没有传统方法.有没有办法解决这个问题,仍然可以在一周中将所有缩写字母大写,而不会触及月份?
在此先感谢所有回复的人.
我的应用程序中有一个UITableView,我想通过单击一个按钮向其中动态添加行。当用户单击我的按钮时,将调用以下方法:
- (IBAction)addChoice:(id)sender {
//addRow is a boolean variable that is set so that we can use it to check later and add a new row
if (!self.addRow) {
self.addRow = YES;
}
[self setEditing:YES animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
然后调用:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.choiceTable setEditing:editing animated:animated];
}
Run Code Online (Sandbox Code Playgroud)
问题是,尽管我已经实现了UITableViewDelegate和UITableViewDataSource,但我已经实现的以下委托方法都没有被调用:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.addRow) {
return UITableViewCellEditingStyleInsert;
} else {
return UITableViewCellEditingStyleDelete;
}
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray *indexPathArray = [NSArray arrayWithObject:indexPath]; …Run Code Online (Sandbox Code Playgroud) 我UITableView在我的应用程序中有UITableViewCell一个包含a的自定义UITextField.我想要做的是从该行中选择特定文本字段时获取行的正确索引.不幸的是,如果我实际点击该行,我只能获得行的正确索引,而不是当我选择文本字段本身时.我正在实现<UITextFieldDelegate>,当我选择一个特定的时候UITextField,我调用该方法:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
int rowTest = [_table indexPathForSelectedRow].row;
int rowTest1 = [_cell.tireCodeField tag];
NSLog(@"the current row is: %d", rowTest1);
NSLog(@"and this row is: %d", rowTest);
return YES;
}
Run Code Online (Sandbox Code Playgroud)
问题是,我得到的行的值来自方法:
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
...
}
Run Code Online (Sandbox Code Playgroud)
得到的.就好像UITextField它所在表中的行和行之间存在脱节.有没有办法让我选择一个特定的textField,然后得到
有没有办法通过选择行中的索引来获取行的索引UITextField,而不是选择行本身?
在此先感谢所有回复的人.
ios ×7
objective-c ×3
iphone ×2
uitableview ×2
uitextfield ×2
annotations ×1
callouts ×1
cllocation ×1
currency ×1
eclipse ×1
geolocation ×1
java ×1
jsp ×1
mapkit ×1
nsdate ×1
tomcat ×1
uibutton ×1
uiimage ×1
uiimageview ×1
xcode ×1