私はUITextViewsが移動されているピクセルの数に基づいてUIViewとUIScrollViewのサイズを変更しています。私はすべてのピクセルがint
変数に格納されています。私はこれを使用しているこれらのテキストビューのすべてを移入するために私の方法の終わりに:ビューのサイズ変更。私が計画した通りに動作しません
viewHeight += viewPixelsToBeAdded;
viewHeight -= viewPixelsToBeRemoved;
detailsView.frame = CGRectMake(0, 20, 320, viewHeight);
realDetailsView.frame = CGRectMake(0, 20, 320, viewHeight);
viewHeightは、私は総画素数を保持するためにviewPixelsToBeAdded
とviewPixelsToBeRemoved
を使用しています1475ある一定のビューの高さでありますビューのサイズを変更する必要があることを示します。上記のコードを使用すると...私のscrollView(detailsView)はスクロールを停止します。全体として。私は私のオブジェクトをビューの中に持っています。そのビューはscrollViewの内部にあります。このようなもののサイズを変更する簡単な方法はありますか?なぜ、私のscrollViewの高さを増減すると、スクロールが止まるのですか?どんな助けでも大歓迎です。必要に応じて、populateLabelsメソッド全体を投稿することができます。とにかく長い道のりをとっているような気がします。
-(void) populateLabels {
NSString *noInfo = (@"No Information Available");
lblCgName.text = _Campground.campground;
NSString *cgLoc = _Campground.street1;
NSString *cgCity = _Campground.city;
NSString *cgState = _Campground.state1;
NSString *cgCountry = _Campground.country;
NSString *cgZipPostal = _Campground.zipPostal;
cgLoc = [[cgLoc stringByAppendingString:@", "] stringByAppendingString:cgCity];
cgLoc = [[cgLoc stringByAppendingString:@", "] stringByAppendingString:cgState];
cgLoc = [[cgLoc stringByAppendingString:@", "] stringByAppendingString:cgCountry];
cgLoc = [[cgLoc stringByAppendingString:@" "] stringByAppendingString:cgZipPostal];
lblCgLoc.text = cgLoc;
double dRate = [_Campground.regRate1 doubleValue];
double dRate2 = [_Campground.regRate2 doubleValue];
NSString *rate = [[NSString alloc] initWithFormat:@"$%0.2f",dRate];
NSString *rate2 = [[NSString alloc] initWithFormat:@"$%0.2f",dRate2];
if ([rate2 isEqualToString:@"$0.00"]) {
lblRate.text = rate;
} else {
rate = [[rate stringByAppendingString:@" - "] stringByAppendingString:rate2];
lblRate.text = rate;
}
double dPaRate = [_Campground.paRate1 doubleValue];
double dPaRate2 = [_Campground.paRate2 doubleValue];
NSString *paRate = [[NSString alloc] initWithFormat:@"$%0.2f",dPaRate];
NSString *paRate2 = [[NSString alloc] initWithFormat:@"$%0.2f",dPaRate2];
if ([paRate2 isEqualToString:@"$0.00"]) {
lblPaRate.text = paRate;
} else {
paRate = [[paRate stringByAppendingString:@" - "] stringByAppendingString:paRate2];
lblPaRate.text = paRate;
}
lblLocal1.text = _Campground.localPhone1;
lblLocal2.text = _Campground.localPhone2;
lblTollFree.text = _Campground.tollFree;
lblFax.text = _Campground.fax;
lblEmail.text = _Campground.email;
lblWebsite.text = _Campground.website;
NSString *gps = _Campground.latitude;
NSString *longitude = _Campground.longitude;
gps = [[gps stringByAppendingString:@", "] stringByAppendingString:longitude];
lblGps.text = gps;
int viewHeight = 1475;
int textViewDefaultHeight = 128;
int newTextViewHeight = 0;
int highlightsPixelsRemoved = 0;
int highlightsPixelsAdded = 0;
int notesPixelsRemoved = 0;
int notesPixelsAdded = 0;
int directionsPixelsRemoved = 0;
int directionsPixelsAdded = 0;
int rentalsPixelsRemoved = 0;
int rentalsPixelsAdded = 0;
int viewPixelsToBeRemoved = 0;
int viewPixelsToBeAdded = 0;
//----------------------------------------------------------------------------
txtHighlights.text = _Campground.highlights;
[self fitFrameToContent:txtHighlights];
newTextViewHeight = txtHighlights.contentSize.height;
if (newTextViewHeight > textViewDefaultHeight) {
highlightsPixelsAdded = newTextViewHeight - textViewDefaultHeight;
viewPixelsToBeAdded += highlightsPixelsAdded;
txtTentsHead.frame = CGRectOffset(txtTentsHead.frame, 0, highlightsPixelsAdded);
txtTents.frame = CGRectOffset(txtTents.frame, 0, highlightsPixelsAdded);
txtNotesHead.frame = CGRectOffset(txtNotesHead.frame, 0, highlightsPixelsAdded);
txtNotes.frame = CGRectOffset(txtNotes.frame, 0, highlightsPixelsAdded);
txtDirectionsHead.frame = CGRectOffset(txtDirectionsHead.frame, 0, highlightsPixelsAdded);
txtDirections.frame = CGRectOffset(txtDirections.frame, 0, highlightsPixelsAdded);
txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, highlightsPixelsAdded);
txtRentals.frame = CGRectOffset(txtRentals.frame, 0, highlightsPixelsAdded);
} else if (newTextViewHeight < textViewDefaultHeight) {
highlightsPixelsRemoved = textViewDefaultHeight - newTextViewHeight;
viewPixelsToBeRemoved += highlightsPixelsRemoved;
txtTentsHead.frame = CGRectOffset(txtTentsHead.frame, 0, -highlightsPixelsRemoved);
txtTents.frame = CGRectOffset(txtTents.frame, 0, -highlightsPixelsRemoved);
txtNotesHead.frame = CGRectOffset(txtNotesHead.frame, 0, -highlightsPixelsRemoved);
txtNotes.frame = CGRectOffset(txtNotes.frame, 0, -highlightsPixelsRemoved);
txtDirectionsHead.frame = CGRectOffset(txtDirectionsHead.frame, 0, -highlightsPixelsRemoved);
txtDirections.frame = CGRectOffset(txtDirections.frame, 0, -highlightsPixelsRemoved);
txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, -highlightsPixelsRemoved);
txtRentals.frame = CGRectOffset(txtRentals.frame, 0, -highlightsPixelsRemoved);
}
//----------------------------------------------------------------------------
txtTents.text = _Campground.tents;
//----------------------------------------------------------------------------
txtNotes.text = _Campground.notes;
[self fitFrameToContent:txtNotes];
newTextViewHeight = txtNotes.contentSize.height;
if (newTextViewHeight > textViewDefaultHeight) {
notesPixelsAdded = newTextViewHeight - textViewDefaultHeight;
viewPixelsToBeAdded += notesPixelsAdded;
txtDirectionsHead.frame = CGRectOffset(txtDirectionsHead.frame, 0, notesPixelsAdded);
txtDirections.frame = CGRectOffset(txtDirections.frame, 0, notesPixelsAdded);
txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, notesPixelsAdded);
txtRentals.frame = CGRectOffset(txtRentals.frame, 0, notesPixelsAdded);
} else if (newTextViewHeight < textViewDefaultHeight) {
notesPixelsRemoved = textViewDefaultHeight - newTextViewHeight;
viewPixelsToBeRemoved += notesPixelsRemoved;
txtDirectionsHead.frame = CGRectOffset(txtDirectionsHead.frame, 0, -notesPixelsRemoved);
txtDirections.frame = CGRectOffset(txtDirections.frame, 0, -notesPixelsRemoved);
txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, -notesPixelsRemoved);
txtRentals.frame = CGRectOffset(txtRentals.frame, 0, -notesPixelsRemoved);
}
//----------------------------------------------------------------------------
txtDirections.text = _Campground.directions;
[self fitFrameToContent:txtDirections];
newTextViewHeight = txtDirections.contentSize.height;
if (newTextViewHeight > textViewDefaultHeight) {
directionsPixelsAdded = newTextViewHeight - textViewDefaultHeight;
viewPixelsToBeAdded += directionsPixelsAdded;
txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, directionsPixelsAdded);
txtRentals.frame = CGRectOffset(txtRentals.frame, 0, directionsPixelsAdded);
} else if (newTextViewHeight < textViewDefaultHeight) {
directionsPixelsRemoved = textViewDefaultHeight - newTextViewHeight;
viewPixelsToBeRemoved += directionsPixelsRemoved;
txtRentalsHead.frame = CGRectOffset(txtRentalsHead.frame, 0, -directionsPixelsRemoved);
txtRentals.frame = CGRectOffset(txtRentals.frame, 0, -directionsPixelsRemoved);
}
//----------------------------------------------------------------------------
txtRentals.text = _Campground.rentals;
[self fitFrameToContent:txtRentals];
newTextViewHeight = txtRentals.contentSize.height;
if (newTextViewHeight > textViewDefaultHeight) {
rentalsPixelsAdded = newTextViewHeight - textViewDefaultHeight;
viewPixelsToBeAdded += rentalsPixelsAdded;
} else if (newTextViewHeight < textViewDefaultHeight) {
rentalsPixelsRemoved = textViewDefaultHeight - newTextViewHeight;
viewPixelsToBeRemoved += rentalsPixelsRemoved;
}
viewHeight += viewPixelsToBeAdded;
viewHeight -= viewPixelsToBeRemoved;
detailsView.frame = CGRectMake(0, 20, 320, viewHeight);
scrollView.frame = CGRectMake(0, 20, 320, viewHeight);
}
私たちは文脈を持つように、いくつかのコードを投稿してください。また、(これは関連する問題ではありませんが)、UIKitのサイズは通常int値ではなくCGFloatを使用します。また、「スクロールを止める」とはどういう意味ですか?現在のスクロールアニメーションが停止している、またはスクロールがそれ以降は機能しないことを意味しますか? – fzwo
スクロールを停止すると、480pxを超えるものは見えません。表示されるのは、iPhoneのデフォルトサイズでポップアップするものだけです。それ以下のものはスクロールしません。私はpopulateLabelsメソッドを投稿しました。私はあなたが必要とする何かを含めることができます。 – tallybear
ビュー自体が実際にサイズ変更されています。背景色を付けてチェックしました。これは、サイズを変更しないscrollViewです。私はscrollViewを設定して、一度にdetailsViewを設定しました。そうでなければスクロールしません。今私はビュー自体をdetailsViewに設定し、魔法のように...まだスクロールしています。これで、scrollViewのサイズを正しく変更する方法を理解する必要があります。 – tallybear