我在iphone的stackoverflow上找到各种电话号码验证,但似乎都没有验证它们似乎只是改变了格式.示例电话号码格式.
目标:通过警报输入此号码.北美人有或没有破折号.
所以有一些代码,但每一件事都是无效的任何想法.
- (void)textFieldDidEndEditing:(UITextField *)textField {
NSString *str=@"^\\+(?:[0-9] ?){6,14}[0-9]$";
NSPredicate *no=[NSPredicate predicateWithFormat:@"SELF MATCHES %@",str];
if([no evaluateWithObject:textField.text]==NO)
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Warning" message:@"Please Enter correct contact no." delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
else{
NSString *textValue = textField.text;
NSLog(@"Value: %@", textValue);
}
}
Run Code Online (Sandbox Code Playgroud) 所以我创建了一个按钮.我希望它有圆角而没有制作圆形.png文件我可以设置背景图像.我可以绕过角落.但是,当我设置背景图像时,圆角会消失.
我很久以前就这样做了一次,但似乎无法让它恢复正常.如何才能做到这一点?
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 addTarget:self action:@selector(goSpecials)
forControlEvents:UIControlEventTouchUpInside];
[button1 setTitle:@"Specials" forState:UIControlStateNormal];
button1.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:(15.0)];
[button1 setTitleColor:[self colorWithHexString:buttonColor] forState:UIControlStateNormal];
button1.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"button.png"]];
//[button1 setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
button1.frame = CGRectMake(20.0, 232.0, 135.0, 32.0);
button1.layer.borderColor = [UIColor blackColor].CGColor;
button1.layer.borderWidth = 0.5f;
button1.layer.cornerRadius = 8.0f;
[self.view addSubview:button1];
Run Code Online (Sandbox Code Playgroud)
button.png:

我需要在使用webview时从隐藏的div标签中提取值.我在我的webview活动中打开了javascript但不喜欢"".我如何实现目标?
public class buttonOne extends Activity{
WebView wb = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.buttons);
wb = new WebView(this);
wb.getSettings().setJavaScriptEnabled(true);
wb.setWebViewClient(new HelloWebViewClient());
wb.getSettings().setJavaScriptEnabled(true);
wb.loadUrl("http://ishopstark.com/mobileapp.php?category=1");
setContentView(wb);
}
private class HelloWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
<script type="text/javascript">
{
var varSendText = document.getElementById("sendtextcoupon").value;
}
</script>
return true;
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个视图控制的应用程序.在我的xib上我没有webview,但我确实有按钮可以调出带有webview的类.所以按下按钮一,然后弹出一个uiwebview,等等.
现在在我的一个课程中,我拉出一个有链接的远程网页.我想用shouldStartLoadwithrequest覆盖那个按钮链接.从来没有像现在这样被称呼.
现在我的班叫做Tenth.m,我的视图控制器中有这个代码
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@" Test spot 1");
NSString* scheme = [[request URL] scheme];
if ([@"didTap" isEqual:scheme]) {
// Call your method
NSLog(@" Test spot 2");
[self didTapButton1];
return NO;
} else {
NSLog(@" Test spot 3");
return YES;
}}
Run Code Online (Sandbox Code Playgroud)
但我什么都没得到(我的NSLog都没有).我已经尝试将它放入我的Tenth.m课程中,但仍然没有.我查看了其他示例,甚至下载了一个但它只使用了viewcontroller和delegates类.没有第三类.
我迷失了为什么它没有被召唤.
这是我的第三堂课
#import "Tenth.h"
@implementation Tenth
- (void)awakeFromNib
{
[category10 loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.mywebsite.com/api/didtap.php"]]];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} …Run Code Online (Sandbox Code Playgroud) 嗨,我正在使用android,我正试图在这个类周围放一个"if"语句但是我得到错误"令牌上的语法错误"如果",无效的AnnotationName"任何帮助?
private String str = "0";
if(str == 0){
public boolean onKeyDown(int keyCode, KeyEvent event)
{
//Handle the back button
if(keyCode == KeyEvent.KEYCODE_BACK)
{
//Ask the user if they want to quit
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Coupon")
.setMessage("Do you want a coupon texted to you?")
.setPositiveButton("YES!", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
//Stop the activity
Toast.makeText(buttonOne.this, "Great! You'll get one in just a couple of minutes.", Toast.LENGTH_LONG).show();
finish();
}
})
.setNegativeButton("Not now", new DialogInterface.OnClickListener()
{
@Override …Run Code Online (Sandbox Code Playgroud) 在我的webview中,我将 通过Android浏览器将其视为移动网站http://www.nsopw.gov/Core/OffenderSearchCriteria.aspx.
但是在我的webview应用程序中,它被视为不是移动浏览器,因此没有被重定向到移动版本.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.buttons);
wb = new WebView(this);
wb.getSettings().setJavaScriptEnabled(true);
wb.setWebViewClient(new HelloWebViewClient());
wb.getSettings().setSupportZoom(true);
wb.getSettings().setBuiltInZoomControls(true);
wb.getSettings().setDomStorageEnabled(true);
String[] loading = getResources().getStringArray(R.array.array_loading);
Random r = new Random();
int rN = r.nextInt(12 - 1) + 1;
progressBar = ProgressDialog.show(Sex_Offenders.this, loading[rN],
"Loading...");
final String urlToLoad ="http://www.nsopw.gov/Core/OffenderSearchCriteria.aspx";
//final String urlToLoad = "http://m.familywatchdog.us/m_v2/msa.asp?es=&l=0&w=0&brtp=html&rstp=xlarge&imgtp=jpg&imgw=310&imgh=320";
wb.setWebViewClient(new HelloWebViewClient() {
public void onPageFinished(WebView view, String url) {
if (progressBar.isShowing()) {
progressBar.dismiss();
}
}
});
Context context = getApplicationContext();
if (Repeatables.isNetworkAvailable(context) == true) { …Run Code Online (Sandbox Code Playgroud) android ×3
ios ×3
iphone ×3
ipad ×1
java ×1
javascript ×1
objective-c ×1
validation ×1
webview ×1