我在将十六进制代码转换为NSColor时遇到了一些麻烦.请注意,这适用于Mac App(因此是NSColor而不是UIColor).这是我到目前为止的代码:
- (NSColor *) createNSColorFromString:(NSString *)string {
NSString* hexNum = [string substringFromIndex:1];
NSColor* color = nil;
unsigned int colorCode = 0;
unsigned char red, green, blue;
if (string) {
NSScanner* scanner = [NSScanner scannerWithString:hexNum];
(void) [scanner scanHexInt:&colorCode];
}
red = (unsigned char) (colorCode >> 16);
green = (unsigned char) (colorCode >> 8);
blue = (unsigned char) (colorCode);
color = [NSColor colorWithCalibratedRed:(float)red / 0xff green:(float)green / 0xff blue:(float)blue / 0xff alpha:1.0];
return color;
Run Code Online (Sandbox Code Playgroud)
}
任何帮助,将不胜感激.
我试图使用[myTable numberofRowsInSection:1]获取UITableView中的行数,并且我总是得到2147483647.无论实际显示多少行.我想要做的就是得到一个数字,用于给定数据源的表格中显示的数字行.数据填充得很好.
好的,我正在尝试使用Xamarin.Auth对Xamarin.iOS进行非常基本的身份验证,并收到错误:"应用程序配置不允许给定URL:一个或多个给定的URL不允许应用程序的设置.它必须与网站URL或Canvas URL匹配,或者域必须是App域之一的子域."
我已经谷歌搜索了一段时间,似乎你可能再也无法使用Xam.Auth进行Facebook - 这似乎不太可能......
这是我的示例代码(没有我的FB应用程序ID) - 您会注意到它实际上是Xam的示例代码的副本:
using System;
using System.Collections.Generic;
using System.Json;
using System.Linq;
using System.Threading.Tasks;
using MonoTouch.Dialog;
#if __UNIFIED__
using Foundation;
using UIKit;
#else
using MonoTouch.Foundation;
using MonoTouch.UIKit;
#endif
namespace Xamarin.Auth.Sample.iOS
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
void LoginToFacebook (bool allowCancel)
{
var auth = new OAuth2Authenticator (
clientId: "SOME_ID",
scope: "",
authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));
auth.AllowCancel = allowCancel;
// If authorization succeeds or is canceled, .Completed will be …Run Code Online (Sandbox Code Playgroud) objective-c ×2
c# ×1
cocoa ×1
cocoa-touch ×1
facebook ×1
ios ×1
iphone ×1
macos ×1
oauth-2.0 ×1
xamarin ×1