在我的codebehind文件中,我调用此函数:
private void loginAction(object sender, TappedRoutedEventArgs e)
{
Webservice webservice = new Webservice();
webservice.getUser(txtLogin.Text, txtPass.Text);
}
Run Code Online (Sandbox Code Playgroud)
然后在webservice中我这样做:
public void getUser(String user, String password)
{
String strUrl = String.Format("http://*******/nl/webservice/abc123/members/login?email={0}&password={1}",user,password);
startWebRequest(strUrl, loginCallback);
}
private async void loginCallback(IAsyncResult asyncResult)
{
try
{
ReceiveContext received = GetReceiveContextFromAsyncResult(asyncResult, "User");
if (received != null && received.Status == 200)
{
await UserDataSource.AddUser(received.Data);
}
else
{
throw new Exception("failedddd");
}
}
catch (Exception e)
{
}
}
Run Code Online (Sandbox Code Playgroud)
我现在要做的是抛出异常时,显示一个消息框.当我获得状态200时,我导航到de code后面的下一页文件.
我现在的问题是,我如何在我的代码隐藏文件中知道这一点?
提前谢谢了!
编辑 我也有这些帮助方法:
#region HELPERS
private void startWebRequest(string …Run Code Online (Sandbox Code Playgroud) 我刚刚更新了我的OSX El Capitan.现在,当我想更新我的PodFile时,我收到此错误:
pod: command not found
Run Code Online (Sandbox Code Playgroud)
这里有什么帮助?
我想检查一下是否NSDictionary为空.我是这样做的.
mutDictValues = [[[NSUserDefaults standardUserDefaults] objectForKey:@"dicValues"]mutableCopy];
NSLog(@"dictValues are %@",mutDictValues);
if(mutDictValues == NULL){
arrCities = [[NSMutableArray alloc]init];
NSLog(@"no cities seleceted");
}else{
arrCities = [[NSMutableArray alloc]init];
arrCities = [mutDictValues objectForKey:@"cities"];
[self placeCities];
}
Run Code Online (Sandbox Code Playgroud)
但它在这一行崩溃arrCities = [mutDictValues objectForKey:@"cities"];,出现以下错误:
-[__NSCFConstantString objectForKey:]:
Run Code Online (Sandbox Code Playgroud)
有人可以帮我弄这个吗 ?
有人可以帮我这个.
我有以下内容 public enum
public enum OfferViewRow {
case Candidates
case Expiration
case Description
case Timing
case Money
case Payment
}
Run Code Online (Sandbox Code Playgroud)
以下mutableProperty:
private let rows = MutableProperty<[OfferViewRow]>([OfferViewRow]())
Run Code Online (Sandbox Code Playgroud)
在我的init文件中,我使用一些reactiveCocoa来设置我的MutableProperty:
rows <~ application.producer
.map { response in
if response?.application.status == .Applied {
return [.Candidates, .Description, .Timing, .Money, .Payment]
} else {
return [.Candidates, .Expiration, .Description, .Timing, .Money, .Payment]
}
}
Run Code Online (Sandbox Code Playgroud)
但现在问题是,当我试图在我的行中获取枚举的值时,它会抛出错误.请看下面的代码.
func cellViewModelForRowAtIndexPath(indexPath: NSIndexPath) -> ViewModel {
guard
let row = rows.value[indexPath.row],
let response = self.application.value
else {
fatalError("")
}
switch row …Run Code Online (Sandbox Code Playgroud) 我正在使用这些Reachability类进行检查,以便在它关闭时获得互联网连接.
这是我的代码:
IN VIEW DID LOAD:
internetReachable = [Reachability reachabilityForInternetConnection];
[internetReachable startNotifier];
// check if a pathway to a random host exists
hostReachable = [Reachability reachabilityWithHostname:@"www.google.com"];
[hostReachable startNotifier];
Then the notification method
-(void) checkNetworkStatus:(NSNotification *)notice
{
// called after network status changes
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)
{
case NotReachable:
{
NSLog(@"The internet is down. IN AGENDA");
self.internetActive = NO;
break;
}
case ReachableViaWiFi:
{
NSLog(@"The internet is working via WIFI.IN AGENDA");
self.internetActive = YES;
break; …Run Code Online (Sandbox Code Playgroud) 我有以下情况.我们有appstore一个应用程序.上周我们重新创建了应用程序并从scatch开始.我们还开始了一个新的xcode项目.
我的问题是这个.我可以将新项目推送到已经存在的旧应用程序的更新中appstore吗?
亲切的问候
我正在尝试创建多页PDF.我已经按照本教程.这适用于静态文本的XIB文件,然后从代码中添加一个表.但我有ATM的问题是当桌子比一个页面更大时.当表有超过9行时.它应该在下一页继续.
这就是我在代码中所做的.
+(void)drawPDF:(NSString*)fileName
{
NSMutableDictionary *mutDictValues = [[[NSUserDefaults standardUserDefaults] objectForKey:@"dicValues"] mutableCopy];
NSMutableArray *arrSelectedCities = [[mutDictValues objectForKey:@"cities"]mutableCopy ];
if(arrSelectedCities.count <= 8){
// If there are only 8 rows --> we can fit everyting on one page !
// Create the PDF context using the default page size of 612 x 792.
UIGraphicsBeginPDFContextToFile(fileName, CGRectZero, nil);
// Mark the beginning of a new page.
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);
[self drawLabels];
[self drawLogo];
int xOrigin = 50;
int yOrigin = 350; …Run Code Online (Sandbox Code Playgroud) 我想在我的tabbar上设置自定义背景图片.我的图像名为"tabbarBack.png",大小为640x92.在我的代码中,我将它设置为这样.
[[[self tabBarController] tabBar] setBackgroundImage:[UIImage imageNamed:@"tabbarBack.png"]];
Run Code Online (Sandbox Code Playgroud)
当我在设备上测试它时,tabbar是它应该的两倍大?有帮助吗?
亲切的问候
我想为一个节日做一个阵容。你可以在这里看到我想要实现的目标。

您可以向各个方向滚动,水平 - 垂直和从左到右角(不知道正确的英语单词)。如果您在一个部分滚动,其他部分应该随之滚动。
我的问题是知道你怎么能做到这一点?我正在寻找几天才能使其正常工作,但没有找到好的解决方案......
我有一个奇怪的问题.将我的stringDate转换为NSDate后,我的NSDate对象比实际日期少一天
-example- StringDate = 2012年6月30日---> NSDate是2012年6月29日
这是我的代码.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"dd/MM/yyyy"];
NSDate *date = [dateFormatter dateFromString:[genkInfo objectForKey:CALENDAR_DATE]];
Run Code Online (Sandbox Code Playgroud)
我正在改变这个日期,因为我从webservice将其作为字符串返回.Web服务提供以下内容
"date": "30/06/2012"
Run Code Online (Sandbox Code Playgroud)
有人知道这有可能吗?
提前致谢
编辑
好的,所以上面问题的解决方案是设置TimeZone
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT+0:00"]];
Run Code Online (Sandbox Code Playgroud)
但现在我有另一个问题.现在的格式是YYYY-MM-DD,但我想要YYYY-DD-MM
我怎样才能做到这一点?
提前致谢 !
ios ×9
objective-c ×7
iphone ×6
app-store ×1
c# ×1
cocoapods ×1
enums ×1
json ×1
nsdate ×1
nsdictionary ×1
pdf ×1
reachability ×1
swift ×1
swift2 ×1
terminal ×1
uiscrollview ×1
uitabbar ×1
uitableview ×1
xcode ×1