我有一个包含在 UIScrollView 中的 UITextView。UITextView 是根据 UISegmentedControl 动态加载的,但我不知道如何自动换行,以便单词移动到下一行。

.米:
@interface Tester ()
{
UITextView *sponsor;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
sponsorInfo = [ [UITextView alloc] initWithFrame:self.sponsorsScrollView.frame];
[sponsor setEditable:NO];
}
- (IBAction)control:(UISegmentedControl *)sender
{
if (self.sponsorSegmentedControl.selectedSegmentIndex == 0)
{
[self changeGenericAbout:self.cellIndex];
}
else
{
//
}
}
- (void)changeGenericAbout:(int)index
{
if (index == 0)
{
sponsorInfo.text = @"[text in screen shot]";
[sponsor sizeToFit];
[self.sponsorsScrollView addSubview:sponsor];
}
}
Run Code Online (Sandbox Code Playgroud)
如何在 iOS 7+ 中实现自动换行?
我已经创建了一个UIView,我想把谷歌地图放进去.但是,当我将GMSMapview添加到我的UIView时,GMSMapview的底部部分没有扩展到适合UIView.我仍然可以看到我的UIVIew的灰色部分.
这是为什么?

- (void)viewDidLoad
{
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
longitude:151.2086
zoom:6];
GMSMapView *mapView = [GMSMapView mapWithFrame:self.googleMapView.bounds camera:camera];
[self.googleMapView addSubview:mapView];
}
Run Code Online (Sandbox Code Playgroud) 请帮我理解这一点,但我有一个NSMutableArray,其中NSLog包含以下内容:
(
(
{
day = 0;
"end_time" = "21:00";
},
{
day = 0;
"end_time" = "21:00";
},
{
day = 0;
"end_time" = "21:00";
}
)
)
Run Code Online (Sandbox Code Playgroud)
当我执行时[array count],它返回1而不是3.我在数组中看到3个对象,为什么它认为只有1个对象?
也许我不理解?谢谢
我正在尝试在Google地图上方显示操作栏,但我意识到,一旦Google地图打开,它就不会使用我的应用程序,而是Google的应用程序,因此标题栏会消失.
据我所知,使用MapView可以实现这一点,但我不知道如何从使用片段转换到MapView,因为我得到了NullPointerException.
这是AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.test" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapActivity"
android:label="@string/title_activity_map" >
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我的activity_map.xml:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context="org.test.MapActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"
map:cameraTargetLat="35.25215"
map:cameraTargetLng="-112.24659"
map:uiTiltGestures="true"
map:uiZoomGestures="true"
map:uiZoomControls="true" />
Run Code Online (Sandbox Code Playgroud)
我的activity_mapview.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" …Run Code Online (Sandbox Code Playgroud) 我刚刚进入php,我遇到了返回JSON对象的问题.
这是代码:
$stmt->bind_result($image_link, $start_time, $end_time, $viet_performer, $english_performer, $viet_event, $english_event, $day, $stage);
while($stmt->fetch())
{
echo json_encode([["image_link" => $image_link,"start_time" => $start_time, "end_time" => $end_time, "viet_performer" => $viet_performer,
"english_performer" => $english_performer, "viet_event" => $viet_event, "english_event" => $english_event, "day" => $day,
"stage" => $stage]]);
$stmt->bind_result($image_link, $start_time, $end_time, $viet_performer, $english_performer, $viet_event, $english_event, $day, $stage);
}
Run Code Online (Sandbox Code Playgroud)
这基本上输出:
{ "图片链接": "schedule_music.jpg", "START_TIME": "17:00", "END_TIME": "18:30", "viet_performer": "", "english_performer": "", "viet_event":" ","english_event":"Tet Music","day":0,"stage":1} {"image_link":"schedule_music.jpg","start_time":"11:00","end_time":"12 :00" , "viet_performer": "", "english_performer": "", "viet_event": "新罕布什尔州C", "english_event?": "音乐", "天":1, "阶段":0}
//再说一遍
但是,根据JSON验证器,它是一个无效的JSON对象. …
我的问题不在于从一般渠道中检索视频.我只想获得频道创建的所有"播放列表",并检索每个播放列表的缩略图,标题和视频数量.
这是一个youtube频道示例:
如您所见,有许多创建的播放列表.
截至目前,我只能获得最新上传的频道视频,在这种情况下只有5个.
使用以下代码:
let urlString = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=\(playlistID)&key=\(apiKey)"
// Create a NSURL object based on the above string.
let targetURL = NSURL(string: urlString)
// Fetch the playlist from Google.
performGetRequest(targetURL, completion: { (data, HTTPStatusCode, error) -> Void in
if HTTPStatusCode == 200 && error == nil
{
// Convert the JSON data into a dictionary.
let resultsDict = try NSJSONSerialization.JSONObjectWithData(data!, options: []) as! Dictionary<NSObject, AnyObject>
print("resultsDict = \(resultsDict)")
......
}
else
{
print("HTTP Status Code = \(HTTPStatusCode)")
print("Error while …Run Code Online (Sandbox Code Playgroud) 我目前有一个包含图像文件路径的字符串,如下所示:
/Users/user/Library/Developer/CoreSimulator/Devices/Hidden/data/Containers/Data/Application/Hidden/Documents/AppName/2017-07-07_21:14:52_0.jpeg
Run Code Online (Sandbox Code Playgroud)
我正在尝试检索我的图像文件的全名,如下所示: 2017-07-07_21:14:52_0.jpeg
我如何让子字符串从最后一个/文件路径的末尾开始?
我见过与使用子字符串相关的问题:
但是,提供的答案并没有帮助我解决我的具体问题。
我敢肯定这可能很简单,但我一直得到的只是错误的子字符串范围。
谢谢!
ios ×4
objective-c ×3
google-maps ×2
swift ×2
xcode ×2
android ×1
json ×1
php ×1
uiscrollview ×1
uitextview ×1
youtube-api ×1